CMS 3D CMS Logo

Classes | Functions

runall Namespace Reference

Classes

class  testit

Functions

def main

Function Documentation

def runall::main (   argv)

Definition at line 41 of file runall.py.

00042                :
00043 
00044     import getopt
00045     
00046     try:
00047         opts, args = getopt.getopt(argv, "", ["nproc=","dohighstat",'hlt','inFile=','intbld'])
00048     except getopt.GetoptError, e:
00049         print "unknown option", str(e)
00050         sys.exit(2)
00051         
00052 # check command line parameter
00053     np=1
00054     doHighStat=0
00055     hlt = False
00056     inFile = None
00057     intBld = False
00058     for opt, arg in opts :
00059         if opt == "--inFile" :
00060             inFile=arg
00061         if opt == "--nproc" :
00062             np=arg
00063         if opt == "--dohighstat" :
00064             doHighStat=1
00065         if opt in ('--hlt',): # note: trailing comma needed for single arg to indicate tuple
00066             hlt = True
00067         if opt in ('--intbld',): # note: trailing comma needed for single arg to indicate tuple
00068             intBld = True
00069 
00070     if hlt:
00071         print "\nWARNING: option --hlt is deprecated as this is now default.\n"
00072 
00073     if inFile:
00074         commands_standard_file=open(inFile,'r')
00075         lines_standard=commands_standard_file.readlines()
00076         commands_standard_file.close()
00077         lines=lines_standard
00078     else:
00079         commands_standard_file=open('cmsDriver_standard_hlt.txt','r')
00080         lines_standard=commands_standard_file.readlines()
00081         commands_standard_file.close()
00082         lines=lines_standard
00083 
00084         if doHighStat==1:
00085             commands_highstat_file=open('cmsDriver_highstats_hlt.txt','r')
00086             lines_highstat=commands_highstat_file.readlines()
00087             commands_highstat_file.close()
00088 
00089             lines=lines+lines_highstat
00090    
00091 
00092     # for the integration builds, check only these samples:
00093     forIB = [ # from the standard_hlt:
00094              'SingleMuPt10', 'SinglePiPt1', 'SingleElectronPt10', 'SingleGammaPt10',
00095              'MinBias', 'QCD_Pt_80_120', 'ZEE', 'BJets_Pt_50_120','TTbar',
00096              # from the highstats_hlt
00097              'SinglePiE50HCAL', 'H130GGgluonfusion', 'QQH120Inv', 'bJpsiX', 
00098              'JpsiMM', 'BsMM', 'UpsMM', 'CJets_Pt_50_120'
00099              ]
00100     
00101     commands=[]
00102     for line in lines:
00103         if ( line[0]!='#' and
00104            line.replace(' ','')!='\n' ):
00105                linecomponents=line.split('@@@')
00106                if intBld and linecomponents[0].strip() not in forIB: continue
00107                command=linecomponents[1][:-1]
00108                commands.append(command)
00109                print 'Will do: '+command
00110         
00111 
00112     nfail=0
00113     npass=0
00114     report=''
00115 
00116     clist = []
00117     cdone = []
00118     i=0
00119     print 'Running in %s thread(s)' %np
00120 
00121     for command in commands:
00122         print 'Preparing to run %s' %command 
00123         current = testit(command)
00124         clist.append(current)
00125         cdone.append(0)
00126         current.start()
00127 
00128         i=int(np)
00129         while (int(i) >= int(np)): 
00130             i=0
00131             time.sleep(10)
00132             alen=len(cdone)
00133             for j in range(0,alen):
00134                 mystat=cdone[j]
00135                 pingle=clist[j]
00136                 isA=pingle.isAlive()
00137                 if ( isA ): i+=1
00138                 if ( not isA and mystat==0 ): 
00139                     nfail+=pingle.nfail
00140                     npass+=pingle.npass
00141                     report+=pingle.report
00142                     cdone[j]=1
00143                     print pingle.report
00144 #            print 'Number of running threads: %s' % i        
00145 
00146     alen=len(cdone)
00147     for j in range(0,alen):
00148         pingle=clist[j]
00149         mystat=cdone[j]
00150         if ( mystat == 0 ):  
00151             pingle.join()
00152             nfail+=pingle.nfail
00153             npass+=pingle.npass
00154             report+=pingle.report
00155             print pingle.report
00156         
00157     report+='\n %s tests passed, %s failed \n' %(npass,nfail)
00158     print report
00159     
00160     runall_report_name='runall-report.log'
00161     runall_report=open(runall_report_name,'w')
00162     runall_report.write(report)
00163     runall_report.close()
00164     
00165     if hlt:
00166         print "\nWARNING: option --hlt is deprecated as this is now default.\n"