2 from threading
import Thread
4 from Configuration.PyReleaseValidation
import WorkFlow
7 from subprocess
import Popen
10 def __init__(self, wf, noRun=False,dryRun=False,cafVeto=True):
22 self.
wfDir=str(self.wf.numId)+
'_'+self.wf.nameId
27 msg =
"\n# in: " +os.getcwd()
28 if self.
dryRun: msg +=
" dryRun for '"
29 else: msg +=
" going to execute "
30 msg += cmd.replace(
';',
'\n')
33 cmdLog = open(self.
wfDir+
'/cmdLog',
'a')
34 cmdLog.write(msg+
'\n')
39 p = Popen(cmd, shell=
True)
40 ret = os.waitpid(p.pid, 0)[1]
42 print "ERROR executing ",cmd,
'ret=', ret
48 startDir = os.getcwd()
50 if not os.path.exists(self.
wfDir):
51 os.makedirs(self.
wfDir)
53 print "cleaning up ", self.
wfDir,
' in ', os.getcwd()
54 shutil.rmtree(self.
wfDir)
55 os.makedirs(self.
wfDir)
57 preamble =
'cd '+self.
wfDir+
'; '
59 startime=
'date %s' %time.asctime()
63 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
74 return ' > %s 2>&1; ' % (
'step%d_'%(i,)+ID+
'.log ',)
79 for (istepmone,com)
in enumerate(self.wf.cmds):
85 self.retStep.append(0)
86 self.stat.append(
'NOTRUN')
88 if not isinstance(com,str):
89 if self.
cafVeto and (com.location ==
'CAF' and not onCAF):
90 print "You need to be no CAF to run",self.wf.numId
93 self.retStep.append(0)
94 self.stat.append(
'NOTRUN')
98 cmd2 = com.lumiRanges()
100 cmd2 =cmd+cmd2+closeCmd(istep,
'lumiRanges')
101 lumiRangeFile=
'step%d_lumiRanges.log'%(istep,)
102 retStep = self.
doCmd(cmd2)
104 cmd+=closeCmd(istep,
'dasquery')
105 retStep = self.
doCmd(cmd)
107 inFile=
'filelist:step%d_dasquery.log'%(istep,)
115 cmd +=
' --filein '+inFile
118 cmd +=
' --lumiToProcess '+lumiRangeFile
121 if 'HARVESTING' in cmd
and not 134==self.wf.numId
and not '--filein' in cmd:
122 cmd+=
' --filein file:step%d_inDQM.root --fileout file:step%d.root '%(istep-1,istep)
124 if istep!=1
and not '--filein' in cmd:
125 cmd+=
' --filein file:step%s.root '%(istep-1,)
126 if not '--fileout' in com:
127 cmd+=
' --fileout file:step%s.root '%(istep,)
131 cmd+=closeCmd(istep,self.wf.nameId)
132 retStep = self.
doCmd(cmd)
134 self.retStep.append(retStep)
139 self.stat.append(
'FAILED')
146 self.stat.append(
'PASSED')
151 endtime=
'date %s' %time.asctime()
152 tottime=
'%s-%s'%(endtime,startime)
158 for i,s
in enumerate(self.
stat):
159 logStat+=
'Step%d-%s '%(i,s)
160 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