Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-30 04:13:22

0001 #!/usr/bin/env python
0002 import argparse
0003 parser = argparse.ArgumentParser(description="Get the start time of the run")
0004 parser.add_argument("runNumber", type=int)
0005 args = parser.parse_args()
0006 import sqlalchemy
0007 import CondCore.Utilities.conddblib as conddb
0008 session = conddb.connect(url=conddb.make_url()).session()
0009 RunInfo = session.get_dbtype(conddb.RunInfo)
0010 bestRun = session.query(
0011             RunInfo.run_number,
0012             RunInfo.start_time,
0013             RunInfo.end_time
0014         ).filter(
0015             RunInfo.run_number >= args.runNumber
0016         ).first()
0017 if bestRun is None:
0018     raise Exception("Run %s can't be matched with an existing run in the database." % options.runNumber)
0019 bestRun, runStart, runStop = bestRun
0020 from calendar import timegm
0021 bestRunStartTime = timegm(runStart.utctimetuple()) << 32
0022 bestRunStopTime  = timegm(runStop.utctimetuple()) << 32
0023 print("{0} -> best run: {1}, start time {2}, stop time {3}".format(args.runNumber, bestRun, runStart, runStop))
0024 print(bestRunStartTime)