def ProcSeries(cmd,i,njobs,email=False,inName='logIn.log',outName='logOut.log',errName='logErr.log'):
global firstRun
if firstRun:
logIn = open(inName, 'w')
logOut = open(outName, 'w')
logErr = open(errName, 'w')
firstRun = False
else:
logIn = open(inName, 'a')
logOut = open(outName, 'a')
logErr = open(errName, 'a')
inl = os.tmpfile()
outl = os.tmpfile()
errl = os.tmpfile()
print '\033[1;33m-> %s\033[0m [%i of %i]' %(cmd,i+1,njobs)
start = datetime.datetime.now()
if email==False:
proc = call(cmd,shell=True,stdin=inl,stdout=outl,stderr=errl)
else:
proc = call(_Notifier(cmd,i+1,njobs,email),shell=True,stdin=inl,stdout=outl,stderr=errl)
end = datetime.datetime.now()
print 'Process %i of %i completed. Time: %s' %(i+1,njobs,end-start)
_Temp2Perm(inl,logIn,cmd,start,end)
_Temp2Perm(outl,logOut,cmd,start,end)
if errl.tell() != 0:
print '\033[1;31mErrors have occurred!\033[0m (check %s)' %(logErr.name)
_Temp2Perm(errl,logErr,cmd,start,end)
if i==njobs-1:
firstRun = True
评论列表
文章目录