stdoutname = subst.do_substitution(p, p["stdout"])
stdoutfile = open(stdoutname, "wb")
- print("Running command: {}{}".format(' '.join(cmd), (" > " + stdoutname) if stdoutname != None else ""))
+ print("run-command: {}{}".format(' '.join(cmd), (" > " + stdoutname) if stdoutname != None else ""))
rcode = subprocess.call(cmd, stdout=stdoutfile)
+ print("run-command: completed with exit code %i" % rcode)
+
except Exception as e:
- print("Caught exception {}".format(e))
+ print("run-command: caught exception: {}".format(e))
finally:
for l in links:
os.unlink(l)
+ print("run-command: the follow output files will be saved to keep:")
+
+ subprocess.call(["find", ".", "-type", "f", "-printf", "run-command: %12.12s %h/%f\\n"])
+
+ print("run-command: start writing output to keep")
+
out = arvados.CollectionWriter()
out.write_directory_tree(".", max_manifest_depth=0)
- arvados.current_task().set_output(out.finish())
+ outuuid = out.finish()
+ arvados.api('v1').job_tasks().update(uuid=arvados.current_task()['uuid'],
+ body={
+ 'output':outuuid,
+ 'success': (rcode == 0),
+ 'progress':1.0
+ }).execute()
if rcode == 0:
os.chdir("..")
shutil.rmtree("tmpdir")
shutil.rmtree("output")
+ print("run-command: success")
+else:
+ print("run-command: failed")
sys.exit(rcode)