9 import os,sys,time,glob,fnmatch, string, datetime
10 from time
import gmtime, strftime
12 from Ft.Xml.Domlette
import NonvalidatingReader
19 start_date = (datetime.date.today() - datetime.timedelta(period)).isoformat()
24 RNumber = long(rNumber)
29 prefix=
"http://atlas-service-runinformation.web.cern.ch/atlas-service-runinformation/cgi-bin/runnumbers.py?"
30 url=prefix+
"start.date="+start_date+
"%2012:06:00&end.date="+end_date+
"%2012:06:00&format=html"
32 request=urllib2.Request(url)
33 u=urllib2.urlopen(request)
36 DocString_1 = DocString.replace (
'<td>',
' ' )
37 DocString_2 = DocString_1.replace (
'</td>',
' ' )
38 DocString_3 = DocString_2.replace (
'<tr>',
' ' )
39 DocString_4 = DocString_3.replace (
'</tr>',
' ' )
40 DocString_5 = DocString_4.replace (
'<th>Name</th><th>Number</th><th>Start At (UTC)</th><th>Duration</th><th>Partition</th>',
' ' )
43 f=
open(file_name,
'w')
48 if os.path.exists(file_name):
49 f =
open(file_name,
'r')
50 for line
in f.readlines():
51 if line.find(string_pattern)>= 0:
53 Runs.append(
int(ar[1]))
56 print(
"-->ERROR: athena_checkUpload: Can't find input file !")
65 timespan=
str(iov0) +
'-' +
str(iov1)
66 prefix=
'http://coolcherrypy.cern.ch:8080/cooldb/'
68 url = prefix+server+d+schema+d+dbname+folder+
'/timespan/'+timespan+
'/tag/'+tag+
'/channels/'+channels
69 httpHeaders={
'Accept':
'text/xml'}
72 request=urllib2.Request(url,textData, httpHeaders)
73 u=urllib2.urlopen(request)
74 xmlDocString = u.read()
78 def RunListInDB(array, server, schema, dbname, folder, tag, channels):
81 for i
in range(len(array)):
86 derived_string=
channelValueQuery(server, schema, dbname, folder, iovSince, iovUntil, tag, channels)
88 derived=NonvalidatingReader.parseString(derived_string,uri=
"dummy")
89 numNoisyModules=derived.xpath(
u'count(//channel)')
91 if numNoisyModules !=0.0:
92 Array_runsInDB.append(runNumber)
94 Array_runsInDB.append(-999)
101 Array_numNoisyModules=[]
102 if (array[0] != -999):
103 for i
in range(len(array)):
108 derived_string=
channelValueQuery(server, schema, dbname, folder, iovSince, iovUntil, tag, channels)
110 derived=NonvalidatingReader.parseString(derived_string,uri=
"dummy")
111 numNoisyModules=derived.xpath(
u'count(//channel)')
112 if numNoisyModules !=0.0:
113 Array_numNoisyModules.append(numNoisyModules)
115 Array_numNoisyModules.append(-999)
117 return Array_numNoisyModules
121 Array_numNoisyStrips = []
122 if (array[0] != -999):
123 for i
in range(len(array)):
128 derived_string=
channelValueQuery(server, schema, dbname, folder, iovSince, iovUntil, tag, channels)
130 derived=NonvalidatingReader.parseString(derived_string,uri=
"dummy")
131 numNoisyModules=derived.xpath(
u'count(//channel)')
132 if numNoisyModules !=0.0:
134 allDefectStripsList=(derived.xpath(
u"//channel/value[@name='DefectList']"))
138 for strips
in allDefectStripsList:
139 words=strips.firstChild.data.split()
140 for j
in range(len(words)):
143 sep=jk.replace (
'-',
' ' )
145 numNoisyStripsAdds=numNoisyStripsAdds+
int(sep1[1])-
int(sep1[0])
147 numNoisyStrips=numNoisyStrips+len(strips.firstChild.data.split())
149 Array_numNoisyStrips.append(numNoisyStrips + numNoisyStripsAdds)
152 Array_numNoisyStrips.append(-999)
154 return Array_numNoisyStrips
159 if (len(array) != 0):
160 for j
in range(len(array)):
162 NoisyModulesAverage = sum/len(array)
164 NoisyModulesAverage = -999
165 return NoisyModulesAverage
170 for i
in range(len(runs)):
171 print(
"Run: ",runs[i],
" --> Num. noisy modules: ", noisy_mods[i],
" --> Num. noisy channels: ", noisy_strips[i])
173 print(
"--> No information found.")
181 endDate=
str(datetime.date.today())
183 fileName=
"./runs_"+startDate+
"_"+endDate+
".txt"
185 Server=
'ATLAS_COOLPROD'
186 Schema=
'ATLAS_COOLOFL_SCT'
188 Folder=
'/SCT/Derived/Monitoring'
189 Tag=
'SctDerivedMonitoring-003-00'
190 String_Pattern=
'ATLAS'
194 RunsInDB=
RunListInDB(RunsInDBTotal, Server,Schema,Dbname,Folder,Tag,
'*')
200 noisyStripsInDB_lastRun=noisyStripsInDB[0]
203 print(
"------------> Runs in COOL DB since ", startDate,
" until ", endDate,
"<------------")
205 print(
" Average of number noisy modules for the above runs: ", noisyModulesAverageInDB)
206 print(
" Number of nosiy strips in the last uploaded run ", RunsInDB[0],
": ", noisyStripsInDB_lastRun)
207 print(
"--------------------------------------------------------------------------------")