ATLAS Offline Software
Loading...
Searching...
No Matches
AtlRunQueryPageMaker.py
Go to the documentation of this file.
1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3
4import os, re
5
7
8 @classmethod
9 def makePage(cls, body, origQuery=None, extraReplace=None, removeExamples=False):
10 from CoolRunQuery.AtlRunQueryQueryConfig import QC
11 (top, bottom) = cls.getBlankPage(removeExamples=removeExamples)
12 # put in the original query
13 if origQuery is not None:
14 top = top.replace('name="q"','name="q" value="%s"' % origQuery)
15
16 # extra replacements
17 if extraReplace is not None:
18 for pat,repl in extraReplace:
19 p = re.compile(pat,re.S)
20 top = p.sub(repl, top)
21 bottom = p.sub(repl, bottom)
22
23 fh = open("%s/index.html" % QC.datapath, "w")
24 print (top, file = fh)
25 print (body, file = fh)
26 print (bottom, file = fh)
27 fh.close()
28
30
31
32 @classmethod
33 def getBlankPage(cls, removeExamples=False):
34 if '/var/vhost' in os.path.dirname(__file__):
35 page = open("%s/index.html" % os.path.dirname(__file__).replace('CoolRunQuery/html',''))
36 else:
37 page = open("%s/atlas-runquery.html" % os.path.dirname(__file__).replace('python/CoolRunQuery/html','html'))
38 s = page.read()
39 top, bottom = re.match("(.*)<!--INSERTQUERYRESULT-->(.*)", s, re.S|re.M).group(1,2)
40 if removeExamples:
41 top = "".join(re.match("(.*)<!--START_EXAMPLES-->.*<!--END_EXAMPLES-->(.*)", top, re.S|re.M).group(1,2))
42 return (top,bottom)
43
44
45 @classmethod
47 from subprocess import call
48 from CoolRunQuery.AtlRunQueryQueryConfig import QC
49 call("mkdir -p %s/css" % QC.datapath, shell=True)
50 call("cp html/css/atlas-runquery-lb.css %s/css/" % QC.datapath, shell=True)
makePage(cls, body, origQuery=None, extraReplace=None, removeExamples=False)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310