2 from threading
import Thread
4 from Configuration.PyReleaseValidation
import WorkFlow
6 from subprocess
import Popen
9 def __init__(self, wf, noRun=False,dryRun=False,cafVeto=True):
21 self.
wfDir=str(self.wf.numId)+
'_'+self.wf.nameId
26 msg =
"\n# in: " +os.getcwd()
27 if self.
dryRun: msg +=
" dryRun for '"
28 else: msg +=
" going to execute "
29 msg += cmd.replace(
';',
'\n')
32 cmdLog = open(self.
wfDir+
'/cmdLog',
'a')
33 cmdLog.write(msg+
'\n')
38 p = Popen(cmd, shell=
True)
39 ret = os.waitpid(p.pid, 0)[1]
41 print "ERROR executing ",cmd,
'ret=', ret
47 startDir = os.getcwd()
49 if not os.path.exists(self.
wfDir):
50 os.makedirs(self.
wfDir)
52 preamble =
'cd '+self.
wfDir+
'; '
54 startime=
'date %s' %time.asctime()
58 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
69 return ' > %s 2>&1; ' % (
'step%d_'%(i,)+ID+
'.log ',)
74 for (istepmone,com)
in enumerate(self.wf.cmds):
80 self.retStep.append(0)
81 self.stat.append(
'NOTRUN')
83 if not isinstance(com,str):
84 if self.
cafVeto and (com.location ==
'CAF' and not onCAF):
85 print "You need to be no CAF to run",self.wf.numId
88 self.retStep.append(0)
89 self.stat.append(
'NOTRUN')
92 cmd2 = com.lumiRanges()
94 cmd2 =cmd+cmd2+closeCmd(istep,
'lumiRanges')
95 lumiRangeFile=
'step%d_lumiRanges.log'%(istep,)
96 retStep = self.
doCmd(cmd2)
98 cmd+=closeCmd(istep,
'dasquery')
99 retStep = self.
doCmd(cmd)
101 inFile=
'filelist:step%d_dasquery.log'%(istep,)
109 cmd +=
' --filein '+inFile
112 cmd +=
' --lumiToProcess '+lumiRangeFile
114 if 'HARVESTING' in cmd
and not '134' in str(self.wf.numId)
and not '--filein' in cmd:
115 cmd+=
' --filein file:step%d_inDQM.root --fileout file:step%d.root '%(istep-1,istep)
117 if istep!=1
and not '--filein' in cmd:
118 cmd+=
' --filein file:step%s.root '%(istep-1,)
119 if not '--fileout' in com:
120 cmd+=
' --fileout file:step%s.root '%(istep,)
124 cmd+=closeCmd(istep,self.wf.nameId)
125 retStep = self.
doCmd(cmd)
127 self.retStep.append(retStep)
132 self.stat.append(
'FAILED')
139 self.stat.append(
'PASSED')
144 endtime=
'date %s' %time.asctime()
145 tottime=
'%s-%s'%(endtime,startime)
151 for i,s
in enumerate(self.
stat):
152 logStat+=
'Step%d-%s '%(i,s)
153 self.
report=
'%s_%s %s - time %s; exit: '%(self.wf.numId,self.wf.nameId,logStat,tottime)+
' '.
join(
map(str,self.
retStep))+
'\n'
static std::string join(char **cmd)
npass
needs to set self.report