diff --git a/bin/enterRun.py b/bin/enterRun.py new file mode 100755 index 0000000..ffe5e51 --- /dev/null +++ b/bin/enterRun.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import BlackDynamite as BD +import subprocess,os + +################################################################ + +parser = BD.BDParser() +parser.register_params(group="getRunInfo", + params={"run_id":int, "order":str}, + mandatory={"run_id":True}, + help={"run_id":"Select a run_id for switching to it"}) + +params = parser.parseBDParameters() +mybase = BD.Base(**params) + +myrun = BD.Run(mybase) +run_id = params['run_id'] +myrun["id"] = run_id +myrun.id = run_id +run_list = myrun.getMatchedObjectList() + +if (len(run_list) == 0): + print ("no run found with id " + str(run_id)) + sys.exit(1) + +run = run_list[0] +print run +mybase.close() +bashrc_filename = os.path.join('/tmp','bashrc.run{0}'.format(run_id)) +bashrc = open(bashrc_filename,'w') +bashrc.write('export PS1="\\u@\\h:RUN-{0}\\$ "\n'.format(run_id)) +bashrc.write('cd {0}'.format(run['run_path'])) +bashrc.close() +subprocess.call('bash --rcfile {0}'.format(bashrc_filename),shell=True)