13 t = arvados.current_task().tmpdir
15 os.chdir(arvados.current_task().tmpdir)
21 if len(arvados.current_task()['parameters']) > 0:
22 p = arvados.current_task()['parameters']
24 p = arvados.current_job()['script_parameters']
29 r = os.path.basename(v)
30 os.symlink(os.path.join(os.environ['TASK_KEEPMOUNT'], v) , r)
35 return os.path.join(arvados.current_task().tmpdir, 'tmpdir')
37 subst.default_subs["link "] = sub_link
38 subst.default_subs["tmpdir"] = sub_tmpdir
44 for c in p["command"]:
45 cmd.append(subst.do_substitution(p, c))
50 stdoutname = subst.do_substitution(p, p["stdout"])
51 stdoutfile = open(stdoutname, "wb")
53 print("Running command: {}{}".format(' '.join(cmd), (" > " + stdoutname) if stdoutname != None else ""))
55 rcode = subprocess.call(cmd, stdout=stdoutfile)
57 except Exception as e:
58 print("Caught exception {}".format(e))
64 out = arvados.CollectionWriter()
65 out.write_directory_tree(".", max_manifest_depth=0)
66 arvados.current_task().set_output(out.finish())
70 shutil.rmtree("tmpdir")
71 shutil.rmtree("output")