5 from collections
import OrderedDict
6 from time
import time, ctime
9 sam = samweb_client.SAMWebClient(experiment=
'nova')
10 defDataDir=
"${NOVAPRODVALID_DATA}/definitions/current" 11 defDataCache=
"${NOVAPRODVALID_DATA}/definitions/cache" 16 tmp=defDataCache +
"/" + defname +
".pkl" 18 tmp=defDataDir +
"/" + defname +
".pkl" 19 return os.path.expandvars(tmp)
24 outFile =
open(fname,
'w')
26 pickle.dump(defData,outFile)
32 inFile =
open(fname,
'r') 34 data=pickle.load(inFile) 43 if os.path.isfile(pklName):
44 shutil.copy(pklName,cacheName)
46 print "ERROR couldn't find pkl file for", defname
53 self.
summary = {
"file_count":0,
"total_event_count":0,
"total_file_size":0 }
66 if self.
summary != other.summary:
72 print "Fetching data for", self.
name 75 if not os.path.isfile(cacheName):
78 cacheData=pickle.load(
open(cacheName,
'r')) 83 if (
time() - cacheData.queryTimeStamp) < maxCacheLifetime:
101 self.
summary = sam.listFilesSummary(defname=self.
name)
105 if self.
summary[
"file_count"] == 0:
106 self.
summary[
"total_event_count"]=0
107 self.
summary[
"total_file_size"]=0
110 print "ERROR, definition %s not found" % self.
name 111 self.
state=
"bad definition name error" 113 print "ERROR, Timeout getting data for %s" % self.
name 114 self.
state=
"timed out" 116 print "ERROR, HTTP: ", e
117 self.
state=
"http error" 120 self.
state=
"proxy error" 121 except KeyboardInterrupt:
122 print "Stopping because you say so." 125 print "ERROR, unknown exception fetching data for %s" % self.
name 126 self.
state=
"unknown error" 135 if cacheData !=
None:
138 sys.stderr.write(
"Warning:: cache data and current data do not match for %s\n" %self.
name)
143 for key
in self.description.keys():
145 for key
in self.summary.keys():
146 print key,
":", self.
summary[key]
def sameData(self, other)
__dict__
we might want to add a fallback in case dataset exists but query fails
def definitionPickleName(defname, useCache=False)
def cacheDefinitionData(defname)
def loadDefinitionData(defname)
def dumpDefinitionData(defData, useCache=False)
procfile open("FD_BRL_v0.txt")
def fetchData(self, maxCacheLifetime)