4 VERSION =
'$Id: generateDQIndexFiles.py,v 1.4 2009-03-31 15:49:37 ponyisi Exp $'
14 print "!! generateDQIndexFiles !!"
19 os.chdir( installPath )
41 for root, dirs, files
in os.walk(
"."):
43 if "history_plot" in dirs:
44 dirs.remove(
"history_plot")
46 if( name.find(
'run_') > -1 ):
47 removeDir.append(name)
48 if len(removeDir) > 0:
49 stream = root.replace(
"./",
"")
51 proci = stream.find(
"/")
54 proc =
int(stream[:proci])
59 run = rundir.replace(
"run_",
"")
63 procDict = runDict[run]
64 if proc
in procDict.keys():
65 streamList = procDict[proc]
66 procText =
str(proc) +
"/"
67 shortStream = stream.replace(procText,
"")
68 if shortStream.find(
"tmp_") == 0:
69 allTmpDirList.append( (stream,run,proc) )
70 streamList.append(stream)
71 procDict[proc] = streamList
72 runDict[run] = procDict
73 for name
in removeDir:
76 for tmpStream,run,proc
in allTmpDirList:
77 stream = tmpStream.replace(
"tmp_",
"")
78 procDict = runDict[run]
79 streamList = procDict[proc]
80 if stream
in streamList:
81 tmpDir = tmpStream +
"/run_" + run
82 tmpDirList.append(tmpDir)
83 streamList.remove(tmpStream)
85 return runDict, tmpDirList
89 for tmpDir
in tmpDirList:
90 cmd =
"rm -rf %s" % tmpDir
96 reversedRunKeys = [(
int(x), x)
for x
in runDict.keys()]
97 reversedRunKeys.sort()
98 reversedRunKeys.reverse()
99 reversedRunKeys = [x[1]
for x
in reversedRunKeys]; del x
100 for run
in reversedRunKeys:
102 procDict = runDict[run]
103 sortedProcDictKeys = procDict.keys()
104 sortedProcDictKeys.sort()
105 for proc
in sortedProcDictKeys:
106 streamList = procDict[proc]
107 sortedStreamList = [ ]
108 for stream
in streamList:
109 if stream.find(
"Express") != -1:
110 sortedStreamList.append(stream)
111 streamList.remove(stream)
113 tmpSortedList = streamList
115 for stream
in tmpSortedList:
116 sortedStreamList.append(stream)
117 print margin, sortedStreamList
122 import xmlrpclib, time
123 s = xmlrpclib.ServerProxy(
'http://atlasdqm.cern.ch:8080')
124 print "Writing HTML index file..."
125 f =
open(indexFile,
'w')
126 f.write(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n')
127 f.write(
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n')
129 f.write(
'<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n')
130 f.write(
'<title>ATLAS Data-Quality Monitoring: '+project+
'</title>\n')
131 f.write(
'<link rel="stylesheet" href="atlasdqm.css" type="text/css" />\n')
132 f.write(
'<script type="text/javascript" src="AllDirs.js"><!-- dont contract--></script>')
134 f.write(
'<body>\n\n')
135 f.write(
'<h1>'+project+
' Monitoring</h1>\n\n')
136 f.write(
'<p><font class="Note">\n')
137 f.write(
'***Indicates reconstruction is in progress; histograms represent accumulated statistics and are temporary.\n')
138 f.write(
'</font></p>\n\n')
139 f.write(
'<table class="Catalogue">\n')
140 f.write(
'<tr><td><b>Run Number</b></td><td width="20"> </td>\n')
141 f.write(
' <td><b>T0 Iteration</b></td><td width="20"> </td>\n')
142 f.write(
' <td><b>Streams</b></td></tr>\n')
147 reversedRunDictKeys = [(
int(x), x)
for x
in runDict.keys()]
148 reversedRunDictKeys.sort()
149 reversedRunDictKeys.reverse()
150 reversedRunDictKeys = [x[1]
for x
in reversedRunDictKeys]; del x
151 for run
in reversedRunDictKeys:
154 runinfo = s.get_run_information({
'low_run': run,
'high_run': run}).
get(run,
None)
156 mouseovertext =
'Run %s<br/>Run Start: %s<br/>' % (run, time.strftime(
'%Y-%m-%d %H:%M %Z', time.localtime(runinfo[4])))
158 mouseovertext += (
'Run End: %s<br/>' % time.strftime(
'%Y-%m-%d %H:%M %Z', time.localtime(runinfo[5])))
160 mouseovertext += (
'Event Filter Events: %s<br/>' % runinfo[3])
161 mouseovertext += (
'Project Tag: %s<br/>' % runinfo[1])
163 mouseovertext += (
'Partition: %s<br/>' % runinfo[2])
166 procDict = runDict[run]
167 nproc = len(procDict.keys())
168 margin =
' <td rowspan="' +
str(nproc) +
'" valign="top" align="right">'
169 margin +=
'<a href="http://atlas-service-db-runlist.web.cern.ch/atlas-service-db-runlist/cgi-bin/runDetails.py?run=' +
str(run) +
"""" onMouseover="showhint('""" + mouseovertext +
"""', this, event, '400px')">"""
170 margin +=
str(run) +
'</a></td>\n'
171 margin +=
' <td rowspan="' +
str(nproc) +
'"></td>\n'
172 sortedProcKeys = procDict.keys()
173 sortedProcKeys.sort()
174 for proc
in sortedProcKeys:
176 f.write(
'<tr bgcolor="' + bgcolor +
'">\n')
180 f.write(
' <td align="right">' +
str(proc) +
'</td>\n')
181 f.write(
' <td></td>\n')
186 streamList = procDict[proc]
187 sortedStreamList = [ ]
188 for stream
in streamList:
189 if stream.find(
"Express") != -1:
190 sortedStreamList.append(stream)
191 streamList.remove(stream)
193 tmpSortedList = streamList
195 for stream
in streamList:
196 sortedStreamList.append(stream)
198 for stream
in sortedStreamList:
199 link = stream +
'/run_' + run
200 proci = stream.rfind(
"/")
201 shortStream = stream[proci+1:]
202 if shortStream.find(
"tmp_") == 0:
203 shortStream = shortStream.replace(
"tmp_",
"")
206 f.write(
' [<a href="' + link +
'">' + shortStream +
'</a>]')
207 endtext =
' \n'
209 f.write(
'\n </td>\n')
212 writeBGColor =
not writeBGColor
214 f.write(
'</table>\n')
221 print "Writing run list XML file..."
223 f =
open(runListFile,
'w')
224 f.write(
'<?xml version="1.0" encoding="ISO-8859-1"?>\n')
225 f.write(
'<DqFileCatalogue>\n')
229 for root, dirs, files
in os.walk(
"."):
232 if( name.find(
'run_') > -1 ):
233 removeDir.append(name)
234 if len(removeDir) > 0:
235 stream = root.replace(
"./",
"")
238 proci = stream.find(
"/")
241 proc =
int(stream[:proci])
247 run = rundir.replace(
"run_",
"")
254 streamDict[stream] = runList
256 for name
in removeDir:
259 streamList = streamDict.keys()
260 sortedStreamList = []
261 for stream
in streamList:
262 if stream.find(
"Express") != -1:
263 sortedStreamList.append(stream)
264 streamList.remove(stream)
266 tmpSortedList = streamList
268 for stream
in tmpSortedList:
269 sortedStreamList.append(stream)
271 for stream
in sortedStreamList:
272 f.write(
'<Stream id=\'' + stream +
'\'>\n')
273 runList = streamDict[stream]
274 reversedRunList = runList
275 reversedRunList.sort()
276 reversedRunList.reverse()
277 for run
in reversedRunList:
278 address = htmlAddress +
"/" + stream +
"/run_" + run
279 f.write(
'<Run runNumber=\'' + run +
'\'>\n')
280 f.write(
'<html>' + address +
'</html>\n')
282 f.write(
'</Stream>\n')
284 f.write(
'</DqFileCatalogue>\n')
288 cmdi = sys.argv[0].rfind(
"/")
289 cmd = sys.argv[0][cmdi+1:]
291 print "Usage: ", cmd,
"<installPath> <project> <indexFile> <runListFile> <htmlAddress>"
295 if __name__ ==
"__main__":
297 if len(sys.argv) != 6:
301 installPath = sys.argv[1]
302 project = sys.argv[2]
303 indexFile = sys.argv[3]
304 runListFile = sys.argv[4]
305 htmlAddress = sys.argv[5]