CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
o2oSetup.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 '''
5 
6 __author__ = 'Giacomo Govi'
7 
8 import CondCore.Utilities.o2o as o2olib
9 import sys
10 import optparse
11 import argparse
12 
13 def main( argv ):
14 
15  parser = argparse.ArgumentParser()
16  parser.add_argument("-c","--create", type=str, help="create a new O2O job" )
17  parser.add_argument("-1","--enable", type=str, help="enable the O2O job" )
18  parser.add_argument("-0","--disable", type=str, help="disable the O2O job" )
19 
20  parser.add_argument("-t","--tag", type=str, help="the CondDB Tag name")
21  parser.add_argument("-i","--interval", type=str, help="the chron job interval")
22  parser.add_argument("-d","--dev", action="store_true", help="bookkeeping in dev database")
23  parser.add_argument("-p","--private", action="store_true", help="bookkeeping in private database")
24  parser.add_argument("-a","--auth", type=str, help="path of the authentication file")
25  args = parser.parse_args()
26 
27  if not args.create and not args.enable and not args.disable:
28  parser.error("Command not given. Possible choices: create, enable, disable")
29 
30  db_service = None
31  if not args.private:
32  if args.dev:
33  db_service = o2olib.dev_db_service
34  else:
35  db_service = o2olib.prod_db_service
36  mgr = o2olib.O2OJobMgr()
37  ret = -1
38  if mgr.connect( db_service, args.auth ):
39  if args.create:
40  if not args.tag:
41  parser.error("Option 'tag' not provided.")
42  if not args.interval:
43  parser.error("Option 'interval' not provided.")
44  print 'creating...'
45  created = mgr.add( args.create, args.tag, args.interval, True )
46  return created
47  if args.enable:
48  mgr.set( args.enable, True )
49  if args.disable:
50  mgr.set( args.disable, False )
51  ret = 0
52  return ret
53 
54 if __name__ == '__main__':
55 
56  sys.exit(main(sys.argv))
def main
Definition: o2oSetup.py:13
Definition: main.py:1