ATLAS Offline Software
AtlRunQueryPageMaker.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 
4 import os, re
5 
6 class PageMaker:
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)
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.html.AtlRunQueryPageMaker.PageMaker.getBlankPage
def getBlankPage(cls, removeExamples=False)
Definition: AtlRunQueryPageMaker.py:33
python.trfUtils.call
def call(args, bufsize=0, executable=None, stdin=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, message="", logger=msg, loglevel=None, timeout=None, retry=2, timefactor=1.5, sleeptime=10)
Definition: trfUtils.py:155
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.html.AtlRunQueryPageMaker.PageMaker._copySomeFilesToCache
def _copySomeFilesToCache(cls)
Definition: AtlRunQueryPageMaker.py:46
Trk::open
@ open
Definition: BinningType.h:40
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
python.html.AtlRunQueryPageMaker.PageMaker.makePage
def makePage(cls, body, origQuery=None, extraReplace=None, removeExamples=False)
Definition: AtlRunQueryPageMaker.py:9
python.html.AtlRunQueryPageMaker.PageMaker
Definition: AtlRunQueryPageMaker.py:6