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("run-command {}{}".format(' '.join(cmd), (" > " + stdoutname) if stdoutname != None else ""))
55 rcode = subprocess.call(cmd, stdout=stdoutfile)
57 print("run-command completed with exit code %i" % rcode)
59 except Exception as e:
60 print("run-command exception: {}".format(e))
66 print("run-command output:")
68 subprocess.call(["find", ".", "-type", "f", "-printf", "run-command %12.12s %h/%f\\\n"])
70 print("run-command writing to keep")
72 out = arvados.CollectionWriter()
73 out.write_directory_tree(".", max_manifest_depth=0)
74 outuuid = out.finish()
75 arvados.api('v1').job_tasks().update(uuid=arvados.current_task()['uuid'],
78 'success': (rcode == 0),
84 shutil.rmtree("tmpdir")
85 shutil.rmtree("output")
86 print("run-command success")
88 print("run-command failed")