CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
setup_regression.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import sys
3 import getopt
4 import common_db
5 import results_db
6 import reference_db
7 
8 def CmdUsage():
9  print "Command line arguments :"
10  print "--create (-C): creates full regression test db schema"
11  print "--drop (-D): drops full regression test db schema."
12  print "--add (-A): -r [release] -a [arch] -p [path]: adds a reference release into db."
13  print "--erase (-E): -r [release] -a [arch]: remove a reference release from db."
14  print "--list (-L): lists the available reference releases"
15  print "--create_res: creates results db schema"
16  print "--drop_res: drops results db schema."
17  print "--create_ref: creates reference db schema"
18  print "--drop_ref: drops reference db schema."
19 
20 try:
21  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'])
22 except getopt.GetoptError, err:
23  # print help information and exit:
24  print str(err) # will print something like "option -a not recognized"
25  CmdUsage()
26  sys.exit(2)
27 c0flag = False
28 d0flag = False
29 c1flag = False
30 d1flag = False
31 aflag = False
32 eflag = False
33 lflag = False
34 RELEASE = None
35 ARCH = None
36 PATH = None
37 if( len(opts)==0 ):
38  CmdUsage()
39  sys.exit(2)
40 for o, a in opts:
41  if o in ("--create","-C"):
42  c0flag = True
43  c1flag = True
44  elif o in ( "--drop", "-D"):
45  d0flag = True
46  d1flag = True
47  elif o in ("--add","-A" ):
48  aflag = True
49  elif o in ("--erase","-E" ):
50  eflag = True
51  elif o in ("--list","-L" ):
52  lflag = True
53  elif o == "-r":
54  RELEASE = a
55  elif o == "-a":
56  ARCH = a
57  elif o == "-p":
58  PATH = a
59  elif o == "--create_ref":
60  c0flag = True
61  elif o == "--create_res":
62  c1flag = True
63  elif o == "--drop_ref":
64  d0flag = True
65  elif o == "--drop_res":
66  d1flag = True
67  elif o in ("--help","-h"):
68  CmdUsage()
69  sys.exit(2)
70  else:
71  assert False, "unhandled option"
72 
74 refDb = reference_db.ReferenceDB( conn )
75 
76 mainOption = False
77 if(d0flag == True):
78  refDb.drop()
79  mainOption = True
80 if(d1flag == True):
81  resDb.drop()
82  mainOption = True
83 if(c0flag == True):
84  refDb.create()
85  mainOption = True
86 if(c1flag == True):
87  resDb.create()
88  mainOption = True
89 
90 if(aflag == True and mainOption == False):
91  mainOption = True
92  if( RELEASE == None ):
93  print "-r parameter has not been specified."
94  if( ARCH == None ):
95  print "-a parameter has not been specified."
96  if( PATH == None ):
97  print "-p parameter has not been specified."
98  refDb.addRelease(RELEASE, ARCH, PATH)
99 if(eflag == True and mainOption == False):
100  mainOption = True
101  if( RELEASE == None ):
102  print "-r parameter has not been specified."
103  if( ARCH == None ):
104  print "-a parameter has not been specified."
105  refDb.deleteRelease(RELEASE, ARCH)
106 if(lflag == True and mainOption == False ):
107  mainOption = True
108  refDb.read()
109 conn.close()
def createDBConnection
Definition: common_db.py:32
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31