1 import sys,os,commands,subprocess,time
3 if len(commands.getoutput(
'which lar').split())>1:
4 sys.stderr.write(
'No "lar" command found...\n')
8 WORK_DIR=
'/tmp/%s_fakenews' % os.environ[
'USER']
9 OUT_FILE =
'simTestPulse_full.root'
11 if os.path.isdir(WORK_DIR):
12 sys.stderr.write(
'Found already-exisitng work dir "%s" ... remove and try re-run!\n' % WORK_DIR)
15 if os.path.isfile(OUT_FILE):
16 sys.stderr.write(
'Found already-exisitng out file "%s" ... remove and try re-run!\n' % OUT_FILE)
22 proc = subprocess.Popen(
'cd %s;lar -c simtestpulse_driver.fcl' % WORK_DIR,shell=
True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
27 sys.stdout.write(
'Running lar... (%-2d [s])\r' % time_slept)
34 out,err = proc.communicate()
37 print 'Log file created: log.txt'
40 sys.stderr.write(
'Failed running the code (state=%s)! Check log.txt...\n' % str(state))
43 os.system(
'hadd %s %s/simTestPulse.root %s/simTestPulseAna.root' % (OUT_FILE,WORK_DIR,WORK_DIR))
45 print 'Output:',OUT_FILE
47 os.system(
'rm -r %s' % WORK_DIR)
open(RACETRACK) or die("Could not open file $RACETRACK for writing")