Skip to content

Commit

Permalink
Merge pull request #18328 from ggovi/condcore-conddb-tools-improvemen…
Browse files Browse the repository at this point in the history
…ts-4-91X

Fixes and Improvements for conddb tools
  • Loading branch information
cmsbuild committed Apr 19, 2017
2 parents 69d5768 + 4d61a3c commit cfc75a0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
11 changes: 6 additions & 5 deletions CondCore/Utilities/python/o2olib.py
Expand Up @@ -254,7 +254,7 @@ def listJobs( self ):
res = self.session.query(O2ORun.job_name,sqlalchemy.func.max(O2ORun.start_time)).group_by(O2ORun.job_name).order_by(O2ORun.job_name)
for r in res:
runs[r[0]] = str(r[1])
res = self.session.query(O2OJob.name, O2OJob.interval, O2OJob.enabled).all()
res = self.session.query(O2OJob.name, O2OJob.interval, O2OJob.enabled).order_by(O2OJob.name).all()
table = []
for r in res:
row = []
Expand Down Expand Up @@ -478,15 +478,16 @@ def execute(self):

args = parser.parse_args()

self.setup(args)
if args.verbose >=1:
self.setup(args)
return args.func()
else:
try:
return args.func()
self.setup(args)
sys.exit( args.func())
except Exception as e:
print str(e)
return 1
logging.error(e)
sys.exit(1)

def setup(self, args):
self.args = args
Expand Down
1 change: 1 addition & 0 deletions CondCore/Utilities/python/popcon2dropbox.py
Expand Up @@ -107,6 +107,7 @@ def upload( args ):

# run the upload
uploadCommand = 'uploadConditions.py %s' %dbName
ret = 0
try:
pipe = subprocess.Popen( uploadCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
stdout = pipe.communicate()[0]
Expand Down
32 changes: 31 additions & 1 deletion CondCore/Utilities/scripts/conddb
Expand Up @@ -665,6 +665,8 @@ def _get_hlt_fcsr( session, timeType ):
RunInfo = session.get_dbtype(conddb.RunInfo)
lastRun = session.query(sqlalchemy.func.max(RunInfo.run_number)).scalar()
fcsr = lastRun+1
if timeType == 'Time':
raise Exception('Cannot find time for non-existing runs.')
ret = _convert_time( session, timeType, fcsr )
if timeType == 'Run':
logging.info('Found fcsr for hlt: %s' %fcsr)
Expand Down Expand Up @@ -911,6 +913,28 @@ def listGTs_(args):
['GT_name', 'Description', 'Release', 'Insertion_time'],
)

def listRuns_(args):
connection = connect(args)
session = connection.session()
RunInfo = session.get_dbtype(conddb.RunInfo)
output_table(args,
session.query(RunInfo.run_number,RunInfo.start_time,RunInfo.end_time).\
order_by(RunInfo.run_number).\
all(),
['Run_number','Start_time','End_time'],
)

def showFcsr_(args):
connection = connect(args)
session = connection.session()
session = conddb.getSessionOnMasterDB( session, session )
run_hlt_fcsr = _get_hlt_fcsr( session, 'Run' )
lumi_hlt_fcsr = _convert_time( session, 'Lumi', run_hlt_fcsr )
run_pcl_fcsr = _get_prompt_fcsr( session, 'Run' )
lumi_pcl_fcsr = _convert_time( session, 'Lumi', run_pcl_fcsr )
time_pcl_fcsr = _convert_time( session, 'Time', run_pcl_fcsr )
output(args,'FCSR for HLT (last Run started +1): %s ( Lumi: %s, Time: undefined )' %(run_hlt_fcsr,lumi_hlt_fcsr))
output(args,'FCSR for PCL (from Tier0 service) : %s ( Lumi: %s, Time: %s )' %(run_pcl_fcsr,lumi_pcl_fcsr,time_pcl_fcsr), newLine=False)

def list_(args):
connection = connect(args)
Expand Down Expand Up @@ -2019,6 +2043,9 @@ def main():
parser_listGTs = parser_subparsers.add_parser('listGTs', description='Lists the GTs available in the DB.')
parser_listGTs.set_defaults(func=listGTs_)

parser_listRuns = parser_subparsers.add_parser('listRuns', description='Lists all the Runs available in the DB.')
parser_listRuns.set_defaults(func=listRuns_)

parser_diff = parser_subparsers.add_parser('diff', description='Compares the contents of two objects. For tags, their IOVs are compared to determine which ranges have different payloads. For global tags, their tag names are compared. Both objects must be of the same type. If there is more than one valid pair (ambiguity), all diffs are listed.')
parser_diff.add_argument('first', help="Name of the first object (i.e. source, old). This can be a tag's name or a global tag's name. It must exactly match -- if needed, use the search command first to look for it.")
parser_diff.add_argument('second', nargs='?', default=None, help='Name of the second object (i.e. destination, new). Ditto. Default: same as the first object (i.e. useful to compare the same object in different databases).')
Expand Down Expand Up @@ -2070,6 +2097,9 @@ def main():
parser_dump.add_argument('--format', default="xml", choices=['xml', 'raw'], help='Output format. Choice between XML and raw hexdump.')
parser_dump.set_defaults(func=dump)

parser_showFcsr = parser_subparsers.add_parser('showFCSR', description='Dumps the FCSR values for hlt and pcl')
parser_showFcsr.set_defaults(func=showFcsr_)

args = parser.parse_args()

logging.basicConfig(
Expand All @@ -2085,7 +2115,7 @@ def main():

if args.verbose >= 1:
# Include the traceback
args.func(args)
return args.func(args)
else:
# Only one error line
try:
Expand Down

0 comments on commit cfc75a0

Please sign in to comment.