CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CondCore/RegressionTest/python/results_mgr.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import sys
00003 import getopt
00004 import common_db
00005 import results_db
00006 import reference_db
00007 
00008 def CmdUsage():
00009         print "Command line arguments :"
00010         print "--read_sel (-S) --full (-f) -i [runid] -l [test_label] -c [ cand_release:arch]: read the content of the results db"
00011         print "--read (-R): read the content of the results db) db"
00012         print "--del (-D) -i [runid] : delete the result entry for the run"
00013 
00014 try:
00015     opts, args = getopt.getopt(sys.argv[1:], "SRFDi:l:c:h", ['read_sel', 'read','full','del','help'])
00016 except getopt.GetoptError, err:
00017     # print help information and exit:
00018     print str(err) # will print something like "option -a not recognized"
00019     CmdUsage()
00020     sys.exit(2)
00021 rflag = False
00022 sflag = False
00023 fflag = False
00024 dflag = False
00025 T_LABEL = None
00026 RUNID = None
00027 CRELEASE = None
00028 RRELEASE = None
00029 if( len(opts)==0 ):
00030     CmdUsage()
00031     sys.exit(2)    
00032 for o, a in opts:
00033     if o in ("--read","-R" ):
00034         rflag = True
00035     elif o in ("--read_sel","-S" ):
00036         sflag = True
00037     elif o in ("--full","-F" ):
00038         fflag = True
00039     elif o in ("--del","-D" ):
00040         dflag = True
00041     elif o == "-l":
00042         T_LABEL = a
00043     elif o == "-i":
00044         RUNID = a
00045     elif o == "-c":
00046         CRELEASE = a
00047     elif o in ("--help","-h"):
00048         CmdUsage()
00049         sys.exit(2)
00050     else:
00051         assert False, "unhandled option"
00052 
00053 conn = common_db.createDBConnection()
00054 resDb = results_db.ResultsDB( conn ) 
00055         
00056 mainOption = False
00057 if(rflag == True):
00058     resDb.read()
00059 elif(sflag == True):
00060     crel = None
00061     carch = None
00062     if( CRELEASE != None ):
00063             tok = CRELEASE.split(":")
00064             crel = tok[0]
00065             carch = tok[1]
00066     rrel = None
00067     rarch = None
00068     resDb.readSelection( RUNID, T_LABEL, crel, carch, fflag )
00069 elif( dflag == True ):
00070     if( RUNID == None ):
00071             print 'ERROR: runid has not been provided.'
00072     else:
00073             resDb.deleteRun( RUNID )
00074 
00075 conn.close()