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,dasOptions="",jobReport=False):
24 self.
wfDir=str(self.wf.numId)+
'_'+self.wf.nameId
29 msg =
"\n# in: " +os.getcwd()
30 if self.
dryRun: msg +=
" dryRun for '"
31 else: msg +=
" going to execute "
32 msg += cmd.replace(
';',
'\n')
35 cmdLog = open(self.
wfDir+
'/cmdLog',
'a')
36 cmdLog.write(msg+
'\n')
41 p = Popen(cmd, shell=
True)
42 ret = os.waitpid(p.pid, 0)[1]
44 print "ERROR executing ",cmd,
'ret=', ret
50 startDir = os.getcwd()
52 if not os.path.exists(self.
wfDir):
53 os.makedirs(self.
wfDir)
55 print "cleaning up ", self.
wfDir,
' in ', os.getcwd()
56 shutil.rmtree(self.
wfDir)
57 os.makedirs(self.
wfDir)
59 preamble =
'cd '+self.
wfDir+
'; '
61 startime=
'date %s' %time.asctime()
65 if 'cms/caf/cms' in os.environ[
'CMS_PATH']:
76 return ' > %s 2>&1; ' % (
'step%d_'%(i,)+ID+
'.log ',)
81 for (istepmone,com)
in enumerate(self.wf.cmds):
87 self.retStep.append(0)
88 self.stat.append(
'NOTRUN')
90 if not isinstance(com,str):
91 if self.
cafVeto and (com.location ==
'CAF' and not onCAF):
92 print "You need to be no CAF to run",self.wf.numId
95 self.retStep.append(0)
96 self.stat.append(
'NOTRUN')
100 cmd2 = com.lumiRanges()
102 cmd2 =cmd+cmd2+closeCmd(istep,
'lumiRanges')
103 lumiRangeFile=
'step%d_lumiRanges.log'%(istep,)
104 retStep = self.
doCmd(cmd2)
106 cmd+=closeCmd(istep,
'dasquery')
107 retStep = self.
doCmd(cmd)
109 inFile=
'filelist:step%d_dasquery.log'%(istep,)
117 cmd +=
' --filein '+inFile
120 cmd +=
' --lumiToProcess '+lumiRangeFile
123 if 'HARVESTING' in cmd
and not 134==self.wf.numId
and not '--filein' in cmd:
124 cmd+=
' --filein file:step%d_inDQM.root --fileout file:step%d.root '%(istep-1,istep)
126 if istep!=1
and not '--filein' in cmd:
127 cmd+=
' --filein file:step%s.root '%(istep-1,)
128 if not '--fileout' in com:
129 cmd+=
' --fileout file:step%s.root '%(istep,)
131 cmd +=
' --suffix "-j JobReport%s.xml " ' % istep
132 cmd+=closeCmd(istep,self.wf.nameId)
133 retStep = self.
doCmd(cmd)
137 self.retStep.append(retStep)
142 self.stat.append(
'FAILED')
149 self.stat.append(
'PASSED')
154 endtime=
'date %s' %time.asctime()
155 tottime=
'%s-%s'%(endtime,startime)
161 for i,s
in enumerate(self.
stat):
162 logStat+=
'Step%d-%s '%(i,s)
163 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