Functions | |
def | getRunnumberFromFileName |
def | getRunsToBeUploaded |
def | main |
Variables | |
string | loaderconf = '' |
string | lumiauthpath = '' |
string | lumilogpath = '' |
def lumiDBFiller::getRunnumberFromFileName | ( | lumifilename | ) |
Definition at line 26 of file lumiDBFiller.py.
def lumiDBFiller::getRunsToBeUploaded | ( | connectionString, | |
dropbox, | |||
authpath = '' , |
|||
minrun = 180250 |
|||
) |
Definition at line 30 of file lumiDBFiller.py.
00031 : 00032 #print 'authpath ',authpath 00033 # get the last analyzed run 00034 command = 'lumiData2.py -c ' +connectionString+' -P '+authpath+' listrun' 00035 if minrun: 00036 command+=' --minrun '+str(minrun) 00037 statusAndOutput = commands.getstatusoutput(command) 00038 print 'all runs in DB since ',minrun,' : ',statusAndOutput[1] 00039 rlist= eval(statusAndOutput[1]) 00040 if rlist: 00041 lastAnalyzedRunNumber = rlist[-1] 00042 print 'Last run in DB: ', lastAnalyzedRunNumber 00043 else: 00044 print 'No qualified run found in DB' 00045 lastAnalyzedRunNumber=minrun 00046 # check if there are new runs to be uploaded 00047 #command = 'ls -ltr '+dropbox 00048 p=re.compile('^CMS_LUMI_RAW_\d\d\d\d\d\d\d\d_\d\d\d\d\d\d\d\d\d_\d\d\d\d_\d.root$') 00049 files=filter(os.path.isfile,[os.path.join(dropbox,x) for x in os.listdir(dropbox) if p.match(x)]) 00050 files.sort(key=lambda x: os.path.getmtime(os.path.join(dropbox,x))) 00051 #print 'sorted files ',files 00052 #print files 00053 #print qualifiedfiles 00054 lastRaw=files[-1] 00055 lastRecordedRun = getRunnumberFromFileName(lastRaw) 00056 print 'Last lumi file produced by HF: ', lastRaw +', Run: ', lastRecordedRun 00057 00058 # if yes, fill a list with the runs yet to be uploaded 00059 runsToBeAnalyzed = {} 00060 if lastRecordedRun != lastAnalyzedRunNumber: 00061 for file in files: 00062 if len(file.split('_'))!=7: continue 00063 thisrun=getRunnumberFromFileName(file) 00064 #print 'this run ',thisrun 00065 #if thisrun>lastAnalyzedRunNumber and isCollisionRun(str(thisrun),authpath): 00066 if thisrun>lastAnalyzedRunNumber : 00067 runsToBeAnalyzed[str(thisrun)] = file 00068 return runsToBeAnalyzed
def lumiDBFiller::main | ( | ) |
Definition at line 71 of file lumiDBFiller.py.
00072 : 00073 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Lumi Data scan") 00074 parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB') 00075 parser.add_argument('-d',dest='dropbox',action='store',required=True,help='location of the lumi root files') 00076 parser.add_argument('-P',dest='authpath',action='store',required=False,help='auth path') 00077 parser.add_argument('-L',dest='logpath',action='store',required=False,help='log path') 00078 parser.add_argument('-f',dest='loaderconf',action='store',required=True,help='path to loder config file') 00079 parser.add_argument('--minrun',dest='minrun',action='store',required=False,help='minimum run to serch') 00080 args=parser.parse_args() 00081 if args.authpath: 00082 lumiauthpath=args.authpath 00083 if args.logpath: 00084 lumilogpath=args.logpath 00085 loaderconf=args.loaderconf 00086 runsToBeAnalyzed = getRunsToBeUploaded(args.connect,args.dropbox,lumiauthpath,minrun=args.minrun) 00087 00088 runCounter=0 00089 rs=runsToBeAnalyzed.keys() 00090 rs.sort() 00091 for run in rs: 00092 runCounter+=1 00093 if runCounter==1: print 'List of processed runs: ' 00094 print 'Run: ', run, ' file: ', runsToBeAnalyzed[run] 00095 logFile=open(os.path.join(lumilogpath,'loadDB_run'+run+'.log'),'w',0) 00096 00097 # filling the DB 00098 command = '$LOCALRT/test/$SCRAM_ARCH/cmmdLoadLumiDB -r '+run+' -L "file:'+runsToBeAnalyzed[run]+'"'+' -f '+loaderconf+' --debug' 00099 statusAndOutput = commands.getstatusoutput(command) 00100 logFile.write(command+'\n') 00101 logFile.write(statusAndOutput[1]) 00102 if not statusAndOutput[0] == 0: 00103 print 'ERROR while loading info onto DB for run ' + run 00104 print statusAndOutput[1] 00105 00106 # selectstring='"{'+run+':[]}"' 00107 # command = 'lumiValidate.py -c '+args.connect+' -P '+ lumiauthpath+' -runls '+selectstring+' update' 00108 # statusAndOutput = commands.getstatusoutput(command) 00109 # logFile.write(command+'\n') 00110 # logFile.write(statusAndOutput[1]) 00111 # logFile.close() 00112 # if not statusAndOutput[0] == 0: 00113 # print 'ERROR while applying validation flag to run '+ run 00114 # print statusAndOutput[1] 00115 if runCounter == 0: print 'No runs to be analyzed'
string lumiDBFiller::loaderconf = '' |
Definition at line 7 of file lumiDBFiller.py.
string lumiDBFiller::lumiauthpath = '' |
Definition at line 5 of file lumiDBFiller.py.
string lumiDBFiller::lumilogpath = '' |
Definition at line 6 of file lumiDBFiller.py.