13 from pandatools
import PandaToolsPkgInfo
15 print (
"prun needs additional setup, try:")
16 print (
" lsetup panda")
36 'addNthFieldOfInDSToLFN',
44 switches = [
'express',
55 using_nEventsPerJob =
False
58 arg = sample.meta().castDouble(
'nc_' + opt, -1, SH.MetaObject.CAST_NOCAST_DEFAULT)
59 if abs(arg + 1) > 1e-6 :
61 if opt==
"nEventsPerJob":
62 using_nEventsPerJob=
True
64 arg = sample.meta().castString(
'nc_' + opt)
66 cmd += [
"--" + opt +
"=" + arg]
69 if using_nEventsPerJob:
70 cmd = [ x
for x
in cmd
if "nGBPerJob" not in x ]
73 for switch
in switches :
74 arg = sample.meta().castDouble(
'nc_' + switch, 0, SH.MetaObject.CAST_NOCAST_DEFAULT)
76 cmd += [
"--" + switch]
78 arg = sample.meta().castString(
'nc_' + switch)
80 if arg !=
"False" and arg !=
"false" and arg !=
"FALSE" :
81 cmd += [
"--" + switch]
84 internalOpts = [
'exec',
91 for opt
in internalOpts :
92 value = sample.meta().castString(
'nc_' + opt)
93 if opt ==
"exec" and using_nEventsPerJob:
94 value +=
" %SKIPEVENTS %MAXEVENTS"
95 cmd += [
"--" + opt +
"=" + value]
97 if sample.meta().castDouble(
'nc_mergeOutput', 1, SH.MetaObject.CAST_NOCAST_DEFAULT) == 0
or sample.meta().castString(
'nc_mergeOutput').
upper() ==
'FALSE' :
101 cmd += [
"--mergeScript=" + sample.meta().castString(
'nc_mergeScript')]
103 if len(sample.meta().castString(
'nc_EventLoop_SubmitFlags')) :
104 cmd += shlex.split (sample.meta().castString(
'nc_EventLoop_SubmitFlags'))
106 if sample.meta().castDouble(
'nc_showCmd', 0, SH.MetaObject.CAST_NOCAST_DEFAULT) != 0 :
109 if not os.path.isfile(
'jobcontents.tgz') :
111 dummycmd = copy.deepcopy(cmd)
112 dummycmd += [
"--outTarBall=jobcontents.tgz"]
113 if len(sample.meta().castString(
'nc_EventLoop_UserFiles')) :
114 dummycmd += [
"--extFile=jobdef.root,runjob.sh," + sample.meta().castString(
'nc_EventLoop_UserFiles').
replace(
" ",
",")]
117 dummycmd += [
"--extFile=jobdef.root,runjob.sh"]
119 dummycmd += [
"--noSubmit"]
122 out = subprocess.check_output(dummycmd, stderr=subprocess.STDOUT)
123 except subprocess.CalledProcessError
as e:
126 print (
"failed with return code " , e.returncode)
127 print (
"output was:")
131 cmd += [
"--inTarBall=jobcontents.tgz"]
135 out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
136 except subprocess.CalledProcessError
as e:
139 print (
"failed with return code ", e.returncode)
140 print (
"output was:")
146 line = re.findall(
r'TaskID=\d+',
str(out))[0]
147 jediTaskID =
int(re.findall(
r'\d+', line)[0])