10 from optparse
import OptionParser
11 parser = OptionParser(usage =
"usage: %prog arguments", version=
"%prog")
12 parser.add_option(
"-v",
"--verbose", action=
"store_true", dest=
"verbose", help=
"Set verbose mode (default: %default)")
13 parser.add_option(
"-y",
"--alwaysyes", action=
"store_true", dest=
"alwaysyes", help=
"Always answer yes to checks (default: %default)")
14 parser.add_option(
"-i",
"--infile", action=
"store", dest=
"infile", help=
"Input file (default: %default)")
15 parser.add_option(
"-x",
"--xsreffile", action=
"store", dest=
"xsreffile", help=
"Cross section reference file (default: %default)")
16 parser.add_option(
"-t",
"--istest", action=
"store", dest=
"istest", help=
"Is test (no actual upload to AMI) (default: %default)")
17 parser.add_option(
"-d",
"--delim", action=
"store", dest=
"delim", help=
"Delimiter for input file (default: %default)")
18 parser.add_option(
"-e",
"--explanation",action=
"store", dest=
"explanation",help=
"Comment for explanation field (default: %default)")
20 parser.set_defaults(verbose=
False,alwaysyes=
False,infile=
None,xsreffile=basepath+
"InputInformation/CrossSectionReference",istest=
"TRUE",delim=
';',explanation=
None)
22 (opts, args) = parser.parse_args()
24 if not opts.explanation:
25 print "ERROR: No explanation found - Should be JIRA ticket or similar"
27 elif 'CENTRPAGE' not in opts.explanation:
28 print "WARNING: Explanation found, but does not include CENTRPAGE - this should usually be a JIRA ticket"
30 if opts.istest==
"FALSE":
37 print cols.FAIL+
"INFO: THIS IS NOT A TEST - UPLOADING FOR REALS!"+cols.ENDC
39 print cols.OKGREEN+
"INFO: THIS IS A TEST - Nothing will be uploaded!"+cols.ENDC
44 currentfile=UT.getCurrentVals(UT.getDSListFromFile(opts.infile))
45 UT.currentVals=UT.getDetailsFromFile(currentfile)
48 uploadVals=UT.getDetailsFromFile(opts.infile)
52 if ds
in UT.currentVals:
53 print cols.OKGREEN+
"INFO: Working on datset %s"%(ds)+cols.ENDC
54 for param
in uploadVals[ds]:
55 if param
in UT.currentVals[ds]:
56 if len(uploadVals[ds][param].strip())
or uploadVals[ds][param].strip()==
"#UNKNOWN#":
57 if uploadVals[ds][param]!=UT.currentVals[ds][param]:
58 print cols.WARNING+
"INFO: Upload %s = %s (current val = %s)"%(param,uploadVals[ds][param],UT.currentVals[ds][param])+cols.ENDC
59 UT.uploadValue(ds,param,uploadVals[ds][param],opts.explanation,uploadVals[ds][
"crossSectionRef"])
61 print "INFO: Inputted %s value is identical to current DB value (%s) - ignoring"%(param,UT.currentVals[ds][param])
63 print "INFO: %s value empty or unknown - ignoring"%(param)
65 print "WARNING: Parameter %s not found in current AMI vals dictionary for %s"%(param,ds)
67 print "WARNING: Parameter dataset %s not found in current AMI val dictionary"%(ds)