#!/usr/bin/python import MySQLdb import sys import cgi import cgitb cgitb.enable() import os dbhost = "hallddb.jlab.org" dbuser = 'datmon' dbpass = '' dbname = 'data_monitoring' conn=MySQLdb.connect(host=dbhost, user=dbuser, db=dbname) curs=conn.cursor() #runPeriodList = [ 'RunPeriod-2014-10', 'RunPeriod-2015-01', 'RunPeriod-2015-03', # 'RunPeriod-2015-06', 'RunPeriod-2015-12', 'RunPeriod-2016-02', # 'RunPeriod-2016-10', 'RunPeriod-2017-01' ] runPeriodList = [ ] def loadRunPeriodList(): # hacK! global runPeriodList cmd = "select distinct run_period from version_info" curs.execute(cmd) runPeriodList = [ el[0] for el in curs.fetchall() ] # print the HTTP header def printHTTPheader(): print "Content-type: text/html\n\n" # print the HTML head section def printHTMLHead(title): print "" print " " print title print " " def printCSS(): print "" def printJavaScript(): print "" #return the option passed to the script def get_options(): form=cgi.FieldStorage() options = {} # default to latest run period options["run_period"] = runPeriodList[-1] if "runPeriod" in form: options["run_period"] = form["runPeriod"].value return options # print the page header def printPageHeader(theRunPeriod): print "

GlueX Data Versions

" print "
" print "Run Periods:" #print "
" print "
" print "
" def getVersionData(run_period): cmd = "SELECT * FROM version_info WHERE run_period=%s ORDER BY data_type ASC, revision ASC" curs.execute(cmd, [run_period]) rows=curs.fetchall() return rows #mysql> describe version_info; #+-------------------+--------------+------+-----+---------+----------------+ #| Field | Type | Null | Key | Default | Extra | #+-------------------+--------------+------+-----+---------+----------------+ #| version_id | int(11) | NO | PRI | NULL | auto_increment | #| data_type | varchar(64) | YES | | NULL | | #| run_period | varchar(64) | YES | | NULL | | #| revision | int(11) | YES | | NULL | | #| software_version | varchar(255) | YES | | NULL | | #| jana_config | varchar(255) | YES | | NULL | | #| ccdb_context | varchar(255) | YES | | NULL | | #| production_time | varchar(64) | YES | | NULL | | #| dataVersionString | varchar(255) | YES | | NULL | | #| skim_name | varchar(255) | YES | | NULL | | #+-------------------+--------------+------+-----+---------+----------------+ def printTableHeader(): print " " print " Data Type" print " Revision" print " CCDB Context" print " Production Date" print " Data Version String" print " Software Versions" print " JANA Config" print " " def printDataTable(run_period,data): basehtmldir = "https://halldweb.jlab.org/data_monitoring/run_conditions/" for field in data: #print "%s ver%d"%(field[1],field[3]) #print str(field[4]) print " " print " %s"%field[1] print " ver%02d"%field[3] print " %s"%field[6] print " %s"%field[7] print " %s"%field[8] if field[4]=="": field[4] == "" print " %s"%field[4] else: print " %s"%(basehtmldir,run_period,field[4],field[4]) if field[5]=="": field[5] == "" print " %s"%field[5] else: print " %s"%(basehtmldir,run_period,field[5],field[5]) print " " def printVersionData(run_period): print "" printTableHeader() data = getVersionData(run_period) printDataTable(run_period,data) print "
" def printHelpText(): #print "

" print "

" print "Description of above fields:" print "" print "" print "" print "" print "" print "" print "" print "" print "" print "
FieldDescription
Data TypeThe class of data: raw, reconstructed, simulated, or some special subset.
RevisionInteger corresponding to a pass through the data
CCDB ContextThe value of JANA_CALIB_CONTEXT, which specifies the version of calibration constants that were used
Production DateThe data at which processing of this data began
Data Version StringA unique string for identifying this data version. This is used in EventStore
Software VersionThe XML file that specifies the software versions used
JANA ConfigThe text file that specifies which JANA options were used
" print "

" print "For detailed information on these values, see GlueX Note 3062" def main(): loadRunPeriodList() # get options that may have been passed to this script options=get_options() # print the HTTP header printHTTPheader() # add some CSS printCSS() # add some JS printJavaScript() # start printing the page print "" # print the head section including the table # used by the javascript for the chart printHTMLHead("GlueX Data Versions") print "" # print the page body #print "" print "" printPageHeader(options["run_period"]) printVersionData(options["run_period"]) print "

 

" printHelpText() print "" print "" conn.close() if __name__=="__main__": main()