Page MenuHomec4science

bashCoat.py
No OneTemporary

File Metadata

Created
Tue, Nov 5, 11:33

bashCoat.py

#!/usr/bin/env python
import run
import os,stat
import subprocess
import re
import socket
admissible_params = {"stdout":None}
#default_params = {}
help = {"stdout":"Specify if you want the standard output instead of a file"}
def launch(run, params):
_exec = run.getExecFile()
head = \
"""#!/bin/bash
export BLACKDYNAMITE_HOST=__BLACKDYNAMITE__dbhost__
export BLACKDYNAMITE_SCHEMA=__BLACKDYNAMITE__study__
export BLACKDYNAMITE_RUN_ID=__BLACKDYNAMITE__run_id__
export BLACKDYNAMITE_USER=$USER
"""
_exec["file"] = run.replaceBlackDynamiteVariables(head) + _exec["file"]
f = open(_exec["filename"], 'w')
f.write(_exec["file"])
f.close()
os.chmod(_exec["filename"], stat.S_IRWXU)
print ("execute ./" + _exec["filename"])
if (params["truerun"]):
run["state"] = "launched"
run.update()
run.commit()
filename = run["run_name"] + ".o" + str(run.id)
filename_err = run["run_name"] + ".e" + str(run.id)
with open(filename, "w") as outfile:
with open(filename_err, "w") as errfile:
ret = subprocess.call("./" + _exec["filename"], stdout=outfile, stderr=errfile)

Event Timeline