def diffLists(self,list1,list2): """Compare two list of run-ranges. Order lists and look first if for intersection between them, if found show difference between list1 and list2""" if list1==list2: return 0 if list1!=list2: if list1[-1][1]<list2[0][0] or list2[-1][1]<list1[0][0]: return 0 if es_init.checkPythonVersion("2.4"): return set(list1)-set(list2) else: for idx in xrange(0,len(list1)): if list1[idx]!=list2[idx]: return list1[idx]
def diffLists(self, list1, list2): """Compare two list of run-ranges. Order lists and look first if for intersection between them, if found show difference between list1 and list2""" if list1 == list2: return 0 if list1 != list2: if list1[-1][1] < list2[0][0] or list2[-1][1] < list1[0][0]: return 0 if es_init.checkPythonVersion("2.4"): return set(list1) - set(list2) else: for idx in xrange(0, len(list1)): if list1[idx] != list2[idx]: return list1[idx]
def checkRunsInDB(self, grade, tStamp): """Check if new list overlap with a list of run-ranges in DB""" if not tStamp: # find out latest timeStamp for that grade tStamp = self.findLatestTimeStamp(grade) # get existing run list from DB newRunList = self.formNewRunList(grade, tStamp) query = """ SELECT minRunNumber,maxRunNumber FROM Version,GraphPath,SpecificVersion WHERE grade='%s' AND timeStamp=%s AND GraphPath.graphid=Version.graphid AND SpecificVersion.svid=GraphPath.svid AND SpecificVersion.svName='%s' """ % (grade, tStamp, self.svName) self.updateDBAndLog(query) tup = self.fetchAll(query) dbGoodRunList = [] for item in tup: dbGoodRunList.append(item) dbGoodRunList.sort() if not dbGoodRunList or not newRunList: return diff = self.diffLists(newRunList, dbGoodRunList) maxRunInES = int(dbGoodRunList[-1][1]) if diff: # check if found difference is still valid for appending to ES if es_init.checkPythonVersion("2.4"): runRange = diff.pop() # here 'diff' is a set of run ranges else: runRange = diff[0] # here 'diff' is a list of run ranges minRunInNew = int(runRange[0]) if minRunInNew <= maxRunInES: print "Found at least one run-range which overlap with run-ranges in ES:" print runRange print "max run in ES is %s, min run in provided list is %s" % ( maxRunInES, minRunInNew) print "To resolve this issue you need to assign a new time stamp for" print "your injection." sys.exit(1)
def checkRunsInDB(self,grade,tStamp): """Check if new list overlap with a list of run-ranges in DB""" if not tStamp: # find out latest timeStamp for that grade tStamp = self.findLatestTimeStamp(grade) # get existing run list from DB newRunList = self.formNewRunList(grade,tStamp) query=""" SELECT minRunNumber,maxRunNumber FROM Version,GraphPath,SpecificVersion WHERE grade='%s' AND timeStamp=%s AND GraphPath.graphid=Version.graphid AND SpecificVersion.svid=GraphPath.svid AND SpecificVersion.svName='%s' """%(grade,tStamp,self.svName) self.updateDBAndLog(query) tup = self.fetchAll(query) dbGoodRunList=[] for item in tup: dbGoodRunList.append(item) dbGoodRunList.sort() if not dbGoodRunList or not newRunList: return diff = self.diffLists(newRunList,dbGoodRunList) maxRunInES = int(dbGoodRunList[-1][1]) if diff: # check if found difference is still valid for appending to ES if es_init.checkPythonVersion("2.4"): runRange = diff.pop() # here 'diff' is a set of run ranges else: runRange = diff[0] # here 'diff' is a list of run ranges minRunInNew = int(runRange[0]) if minRunInNew<=maxRunInES: print "Found at least one run-range which overlap with run-ranges in ES:" print runRange print "max run in ES is %s, min run in provided list is %s"%(maxRunInES,minRunInNew) print "To resolve this issue you need to assign a new time stamp for" print "your injection." sys.exit(1)
#!/usr/bin/env python # # Ported to GlueX by Sean Dobbs ([email protected]), 2014 # # Copyright 2004 Cornell University, Ithaca, NY 14853. All rights reserved. # # Author: Valentin Kuznetsov, 2004 # """ESMoveManager is in charge of moving data in EventStore.""" import os, sys, string, time, glob, stat, shutil import es_init, file_util, sql_util, gen_util from es_init import ESInit, checkArg # include python profiler only if python version greater then 2.3 if es_init.checkPythonVersion("2.3"): import hotshot # Python profiler import hotshot.stats # profiler statistics class ESMoveManager(ESInit): """ESMoveManager is in charge of moving files in EventStore""" def __init__(self, db, dbType, logFile): ESInit.__init__(self, db, dbType, logFile) def moveFilesInES(self, iFileList, fileOut): """High-level method to move a list of files to fileOut destination. All job is done by using L{moveFileInES} method. @type iFileList: list @param iFileList: list of files @type fileOut: string
# # Copyright 2004, 2005 # Cornell University, Ithaca, NY 14853. All rights reserved. # # Author: Valentin Kuznetsov, 2004 # # This utility counts events for given run/grade/timeStamp in EventStore """ESEventCounter counts events for given run/grade/timeStamp in EventStore""" import os, sys, string, re, time import esdb_auth, os_path_util, es_init, gen_util, sql_util, key_dump from es_init import ESInit, checkArg import SOAPpy # include python profiler only if python version greater then 2.3 if es_init.checkPythonVersion("2.3"): import hotshot # Python profiler import hotshot.stats # profiler statistics ##### FIX THIS class MetaData_Services: def __init__(self): CLEO_wsdl = 'http://cougar.cs.cornell.edu/CLEO/CLEO_WS.asmx?WSDL' CLEO_namespace = 'http://cleo.lepp.cornell.edu/CLEO' config = SOAPpy.SOAPConfig () config.debug = 0 config.buildWithNamespacePrefix = False self.proxy = SOAPpy.WSDL.Proxy(CLEO_wsdl,config,namespace=CLEO_namespace,noroot=1)
raise # close connection to db mydb.commit() mydb.close() returnStatus = es_init.ESOutput(status, userCommand, historyFile, outputLog, globalLog) return returnStatus # # main # if __name__ == "__main__": if not es_init.checkPythonVersion("2.4"): print "To run ESBuilder you need to have 2.4 or higher version of python" sys.exit(1) if sys.argv.count('-profile') and es_init.checkPythonVersion("2.3"): # include python profiler only if python version greater then 2.3 import hotshot # Python profiler import hotshot.stats # profiler statistics print "Run ESBuilder/ESManager in profiler mode" profiler = hotshot.Profile("profile.dat") profiler.run("ESBuilder(sys.argv)") profiler.close() stats = hotshot.stats.load("profile.dat") stats.sort_stats('time', 'calls') stats.print_stats() else: status = ESBuilder(sys.argv)
print "--------------- See traceback ----------------" raise # close connection to db mydb.commit() mydb.close() returnStatus = es_init.ESOutput(status, userCommand, historyFile, outputLog, globalLog) return returnStatus # # main # if __name__ == "__main__": if not es_init.checkPythonVersion("2.4"): print "To run ESBuilder you need to have 2.4 or higher version of python" sys.exit(1) if sys.argv.count("-profile") and es_init.checkPythonVersion("2.3"): # include python profiler only if python version greater then 2.3 import hotshot # Python profiler import hotshot.stats # profiler statistics print "Run ESBuilder/ESManager in profiler mode" profiler = hotshot.Profile("profile.dat") profiler.run("ESBuilder(sys.argv)") profiler.close() stats = hotshot.stats.load("profile.dat") stats.sort_stats("time", "calls") stats.print_stats() else: