CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondCore/RegressionTest/python/setup_regression.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 "--create (-C): creates full regression test db schema"
00011         print "--drop (-D): drops full regression test db schema."
00012         print "--add (-A): -r [release] -a [arch] -p [path]: adds a reference release into db."
00013         print "--erase (-E): -r [release] -a [arch]: remove a reference release from db."
00014         print "--list (-L): lists the available reference releases"
00015         print "--create_res: creates results db schema"
00016         print "--drop_res: drops results db schema."
00017         print "--create_ref: creates reference db schema"
00018         print "--drop_ref: drops reference db schema."
00019 
00020 try:
00021     opts, args = getopt.getopt(sys.argv[1:], "CDAELRr:a:p:h", ['create', 'drop', 'add', 'erase', 'list','read','create_res','drop_res','create_ref','drop_ref','help'])
00022 except getopt.GetoptError, err:
00023     # print help information and exit:
00024     print str(err) # will print something like "option -a not recognized"
00025     CmdUsage()
00026     sys.exit(2)
00027 c0flag = False
00028 d0flag = False
00029 c1flag = False
00030 d1flag = False
00031 aflag = False
00032 eflag = False
00033 lflag = False
00034 RELEASE = None
00035 ARCH = None
00036 PATH = None
00037 if( len(opts)==0 ):
00038     CmdUsage()
00039     sys.exit(2)    
00040 for o, a in opts:
00041     if o in ("--create","-C"):
00042         c0flag = True
00043         c1flag = True
00044     elif o in ( "--drop", "-D"):
00045         d0flag = True
00046         d1flag = True
00047     elif o in ("--add","-A" ):
00048         aflag = True
00049     elif o in ("--erase","-E" ):
00050         eflag = True
00051     elif o in ("--list","-L" ):
00052         lflag = True
00053     elif o == "-r":
00054         RELEASE = a
00055     elif o == "-a":
00056         ARCH = a
00057     elif o == "-p":
00058         PATH = a
00059     elif o == "--create_ref":
00060         c0flag = True
00061     elif o == "--create_res":
00062         c1flag = True
00063     elif o == "--drop_ref":
00064         d0flag = True
00065     elif o == "--drop_res":
00066         d1flag = True
00067     elif o in ("--help","-h"):
00068         CmdUsage()
00069         sys.exit(2)
00070     else:
00071         assert False, "unhandled option"
00072 
00073 conn = common_db.createDBConnection()
00074 refDb = reference_db.ReferenceDB( conn )
00075         
00076 mainOption = False
00077 if(d0flag == True):
00078     refDb.drop()
00079     mainOption = True
00080 if(d1flag == True):
00081     resDb.drop()
00082     mainOption = True
00083 if(c0flag == True):
00084     refDb.create()
00085     mainOption = True
00086 if(c1flag == True):
00087     resDb.create()
00088     mainOption = True
00089 
00090 if(aflag == True and mainOption == False):
00091     mainOption = True
00092     if( RELEASE == None ):
00093         print "-r parameter has not been specified."
00094     if( ARCH == None ):
00095         print "-a parameter has not been specified."
00096     if( PATH == None ):
00097         print "-p parameter has not been specified."
00098     refDb.addRelease(RELEASE, ARCH, PATH)
00099 if(eflag == True and mainOption == False):
00100     mainOption = True
00101     if( RELEASE == None ):
00102         print "-r parameter has not been specified."
00103     if( ARCH == None ):
00104         print "-a parameter has not been specified."
00105     refDb.deleteRelease(RELEASE, ARCH)
00106 if(lflag == True and mainOption == False ):
00107     mainOption = True
00108     refDb.read()
00109 conn.close()