3 from __future__
import with_statement, print_function
9 import xml.etree.cElementTree
as ET
15 __import__(grlconfmod)
16 m = sys.modules[grlconfmod]
18 grlobj = grlconfmod.rsplit(
'.')[-1]
19 return m.__dict__[grlobj]()
22 from CoolRunQuery.AtlRunQueryLib
import AtlRunQuery, AtlRunQueryOptions
23 from CoolRunQuery.AtlRunQueryParser
import ArgumentParser
27 config.setdqfolder(folder)
28 config.setdqctag(cooltag)
31 query = config.getsearchquery()
32 print (
">> Calling cmd equivalent of: ")
33 print (
"%s \"%s\"" % (config.querytool,query))
37 atlqueryarg = config.querytool +
" " + ap.ParseArgument( query )
38 (options, args) = AtlRunQueryOptions().
parse(atlqueryarg)
44 proc = multiprocessing.Process(target=AtlRunQuery, args=(options,),
45 kwargs={
'html':
"NO",
'origQuery':query,
'loglevel':0})
48 xmlfile =
'data/'+config.listname
54 sys.path.append(os.path.dirname(grlconf))
56 tmpdir = tempfile.mkdtemp()
60 os.chdir(os.environ[
'TMPDIR'])
63 queue.put((rv, rfile))
67 tagxml = urllib.urlopen(
'http://voatlas11.cern.ch:8080/cooldb/ATLAS_COOLPROD/ATLAS_COOLOFL_GLOBAL/COMP200/GLOBAL/DETSTATUS/%s/tags'
69 xml = ET.parse(tagxml)
71 for t
in xml.findall(
'tag'):
73 lock = t.attrib.get(
'lock',
'unlocked')
74 description = t.attrib.get(
'description')
75 rv.append((text, description, lock))
78 GRL_DIRECTORY=
'/afs/cern.ch/user/a/atlasdqm/grl'
81 TAGS_TO_SUPPRESS = [
'DetStatusLBSumm_m4initial',
82 'DetStatusLBSumm-cos08-01',
83 'DetStatusLBSumm-cos09-01',
84 'DetStatusLBSumm-cos08-02',
86 'DetStatusLBSumm_RECP']
90 def walker(rl, d, children):
91 for child
in children:
92 if child[-3:] ==
'.py' and child !=
'__init__.py':
93 fullpath = os.path.join(d, child)
94 classname = fullpath.replace(GRL_DIRECTORY,
'')[:-3].lstrip(
'/').
replace(
'/',
'.')
95 rl.append((fullpath, classname))
96 os.path.walk(GRL_DIRECTORY, walker, rl)
107 '<title>GRL generator</title>'
108 '<script type="text/javascript" src="/static/js/grl.js"><!-- -->'
110 '</head><body onload="onLoad()">'
111 '<h1>Good Run List Generator</h1>'
112 '<p>This generator allows you to create good run list XML files from '
113 'configurations that are currently kept on AFS, in <tt>~atlasdqm/grl</tt>.'
115 '<p>CoolRunQuery-00-01-92'
116 '<p>GoodRunsLists-00-00-71'
118 rv.append(
'<div><form method="get" action="generate" style="border-width: 2px; border-style:solid">')
119 rv.append(
'Configuration file: <select name="configuration" id="confselect">')
121 rv.append(
'<option value="%(config)s">%(config)s</option>'
123 rv.append(
'</select> <a href="javascript:downloadPython()">(Click to download)</a> <br/>\n')
124 rv.append(
'DQ folder: <select name="folder" id="folderselect" onchange="adjustTagList(this)">\n'
125 '<option value="LBSUMM" selected>LBSUMM: Full DQ summary (default, recommended)</option>\n'
126 '<option value="SHIFTOFL">SHIFTOFL: Offline shifters (experts)</option>\n'
127 '<option value="DQCALCOFL">DQCALCOFL: Automatic checks + online shifters (experts)</option>\n'
128 '</select> If in doubt, leave as LBSUMM<br/>'
130 rv.append(
'COOL tag: <select name="cooltag" id ="cooltagselect">')
131 for folder
in (
'LBSUMM',
'SHIFTOFL',
'DQCALCOFL'):
133 if t
in TAGS_TO_SUPPRESS:
continue
136 apptext.append(
'(%s)' % descr)
137 if lock ==
'unlocked':
138 apptext.append(
'Tag unlocked, all runs may change')
139 elif lock ==
'partial':
140 apptext.append(
'Tag partially locked, recent runs may change')
142 apptext.append(
'Tag locked')
144 apptext.insert(0,
'—')
145 rv.append(
'<option value="%(tag)s">%(tag)s %(apptext)s</option>'
146 % {
'tag': t,
'apptext':
' '.
join(apptext)})
149 '<option value="">HEAD</option>'
152 '<input type="submit" value="Submit"/>\n'
155 rv.append(
'</body></html>')
161 def generate(self, configuration=None, folder='LBSUMM', cooltag='HEAD'):
162 if configuration
is None:
165 q = multiprocessing.Queue()
166 proc = multiprocessing.Process(target=_get_grl_info,
167 args = [os.path.join(GRL_DIRECTORY, configuration),
169 kwargs = {
'queue': q,
'folder': folder})
173 cherrypy.response.headers[
'content-type'] =
'text/xml'
174 cherrypy.response.headers[
'content-disposition'] =
'attachment; filename=%s' % rv[1]