|
ATLAS Offline Software
|
|
def | __init__ (self) |
|
def | content (self, **args) |
|
def | configure (self) |
|
def | pageName (self) |
|
def | addPage (self, name, page, **attrs) |
|
def | addLink (self, name, alias, **attrs) |
|
def | addToPageHeader (self, snippet) |
|
def | index (self, **args) |
|
def | configureLinks (self) |
|
def | override (self) |
|
def | header (self, **args) |
|
def | navigation (self, **args) |
|
def | footer (self, **args) |
|
Definition at line 57 of file MyPlots.py.
◆ __init__()
def MyPlots.MyPlots.__init__ |
( |
|
self | ) |
|
Definition at line 59 of file MyPlots.py.
60 BeamSpotWebPage.__init__(self)
61 self.pageConfig[
'pageTitle'] =
'ATLAS Beam Spot Plots'
◆ addLink()
def WebPage.WebPage.addLink |
( |
|
self, |
|
|
|
name, |
|
|
|
alias, |
|
|
** |
attrs |
|
) |
| |
|
inherited |
Add a new link to the page tree. Links share page objects with
other pages through aliasing. This allows using different links
with different queries to the same page as if they were separate
pages. For links, highlighting of the current page is disabled
(if enabled, all links leading to the same page would be
highlighted).
Definition at line 309 of file WebPage.py.
309 def addLink(self, name, alias, **attrs):
310 """Add a new link to the page tree. Links share page objects with
311 other pages through aliasing. This allows using different links
312 with different queries to the same page as if they were separate
313 pages. For links, highlighting of the current page is disabled
314 (if enabled, all links leading to the same page would be
316 self.globalConfig.pageList.append(name)
317 self.globalConfig.pageAttributes[name] = dict(attrs)
318 self.globalConfig.pageAttributes[name][
'alias'] = alias
◆ addPage()
def WebPage.WebPage.addPage |
( |
|
self, |
|
|
|
name, |
|
|
|
page, |
|
|
** |
attrs |
|
) |
| |
|
inherited |
Add a new web page to the page tree. All pages added via addPage
share the same GlobalConfiguration object.
Definition at line 300 of file WebPage.py.
300 def addPage(self, name, page, **attrs):
301 """Add a new web page to the page tree. All pages added via addPage
302 share the same GlobalConfiguration object."""
303 page.globalConfig = self.globalConfig
304 page.pageConfig[
'pageName'] = name
305 self.globalConfig.pageList.append(name)
306 self.globalConfig.pageAttributes[name] = dict(attrs)
307 setattr(self,name,page)
◆ addToPageHeader()
def WebPage.WebPage.addToPageHeader |
( |
|
self, |
|
|
|
snippet |
|
) |
| |
|
inherited |
Add a snippet of code to the page header. Use this e.g. to include JavaScript libraries.
Definition at line 320 of file WebPage.py.
320 def addToPageHeader(self, snippet):
321 """Add a snippet of code to the page header. Use this e.g. to include JavaScript libraries."""
322 self.pageConfig[
'pageHeaderSnippets'] += snippet
◆ configure()
def BeamSpotWebPage.BeamSpotWebPage.configure |
( |
|
self | ) |
|
|
inherited |
Final configuration of web application after all data is initialized.
Reimplemented from WebPage.WebPage.
Definition at line 49 of file BeamSpotWebPage.py.
50 self.pageConfig[
'cssName'] = self.globalConfig.baseUrl+
'/css/beamspot.css'
51 if not self.pageConfig.
get(
'pageTitle',
''):
52 self.pageConfig[
'pageTitle'] =
'ATLAS Beam Spot Web Page'
53 self.pageConfig[
'header'] = header
54 self.pageConfig[
'footer'] = footer
55 WebPage.configure(self)
◆ configureLinks()
def WebPage.WebPage.configureLinks |
( |
|
self | ) |
|
|
inherited |
Based on configuration data, for each web page create two link entries in pageConfig:
The first entry has the form url_PAGENAME and contains the complete URL to link to
a page. The second entry is named href_PAGENAME and contains style information and a
href= prefix with proper quotation marks in addition to the URL. These link entries
should be used to generate links in HTML pages with snippets like <a %(href_PAGENAME)s>
or <a href="%(url_PAGENAME)>. The link entries can only be generated once all
configuration data is available, ie configureLinks must be called from configure
and not from __init__.
Definition at line 353 of file WebPage.py.
353 def configureLinks(self):
354 """Based on configuration data, for each web page create two link entries in pageConfig:
355 The first entry has the form url_PAGENAME and contains the complete URL to link to
356 a page. The second entry is named href_PAGENAME and contains style information and a
357 href= prefix with proper quotation marks in addition to the URL. These link entries
358 should be used to generate links in HTML pages with snippets like <a %(href_PAGENAME)s>
359 or <a href="%(url_PAGENAME)>. The link entries can only be generated once all
360 configuration data is available, ie configureLinks must be called from configure
361 and not from __init__."""
362 for p
in self.globalConfig.pageList:
363 page = self.globalConfig.pageAttributes[p].
get(
'alias',p)
364 query = self.globalConfig.pageAttributes[p].
get(
'query',
'')
365 style = self.globalConfig.pageAttributes[p].
get(
'style',
None)
366 self.pageConfig[
'url_'+p] =
'%s/%s/%s' % (self.globalConfig.baseUrl,page,query)
367 if p==self.pageName():
368 self.pageConfig[
'href_'+p] =
'href="%s/%s/%s" class="%s"' % (self.globalConfig.baseUrl,page,query,self.pageConfig[
'css_currentLink'])
371 self.pageConfig[
'href_'+p] =
'href="%s/%s/%s" class="%s"' % (self.globalConfig.baseUrl,page,query,style)
373 self.pageConfig[
'href_'+p] =
'href="%s/%s/%s"' % (self.globalConfig.baseUrl,page,query)
◆ content()
def MyPlots.MyPlots.content |
( |
|
self, |
|
|
** |
args |
|
) |
| |
Generate the page content. Default value comes from self.pageConfig['content'].
Reimplemented from WebPage.WebPage.
Definition at line 63 of file MyPlots.py.
66 ntDir = self.globalConfig[
'ntDir']
67 periodDir = ntDir+
'/DataPeriods'
68 cmd = self.globalConfig[
'wwwDir']+
'/run-beamspotnt.sh'
69 if not os.path.exists(cmd):
70 return error(
'Configuration error: %s does not exist or unreadable' % cmd)
71 if not 'plotType' in args:
72 args[
'plotType'] =
'plot'
75 form =
htmlPara(
'Select data and what to plot:', attr =
'class ="example"')
78 projectList =
sorted([ os.path.basename(p)
for p
in glob.glob(periodDir+
'/data*')])
79 form +=
htmlSelect(
'Project tag',
'project', args, projectList,
'all data',
80 attr =
'onchange = "this.form.submit()"')
83 if 'project' in args
and args[
'project']:
84 periodList = glob.glob(periodDir+
'/'+args[
'project']+
'/*')
85 periodList =
sorted([ os.path.basename(p)[:-10]
for p
in periodList ])
86 if 'AllYear' in periodList:
87 periodList.remove(
'AllYear')
88 periodList.insert(0,
'AllYear')
89 if not 'period' in args
and periodList:
90 args[
'period'] = periodList[0]
91 form +=
htmlSelect(
'Period',
'period', args, periodList, attr=
'multiple size=5')
94 if not args.get(
'project'):
101 [
'initial T0 processing::t0/beamspotnt-IndetBeampos-ES1-UPD2.root',
102 'latest data from COOL::cool/beamspotnt-COOL-Current.root'])
106 form +=
htmlSelect(
'Type of plot',
'plotType', args,
107 [
'time evolution::plot',
'summary (slow)::summary',
'histogram::hist'],
108 attr =
'onchange = "this.form.submit()"')
111 if args[
'plotType']!=
'summary':
113 [
'posX',
'posY',
'posZ',
'sigmaX',
'sigmaY',
'sigmaZ',
'tiltX',
'tiltY',
'rhoXY',
'k'])
116 form +=
htmlPara(
'Options:', attr=
'class ="example"')
117 if args[
'plotType']!=
'hist':
118 form +=
htmlCheckbox(
'Use LB instead of time on x axis',
'lbaxis',args)
119 form +=
htmlCheckbox(
'Predefined axis range',
'ydef', args)
121 form +=
htmlTextInput(
'y axis scale expansion factor',
'yscale',args,6,6)
122 if args[
'plotType']==
'plot':
133 form +=
htmlPara(
'Generate plot (depending on what parameters you choose, this may take a while.. please be patient):', attr=
'class ="example"')
134 form +=
htmlCheckbox(
'Show command line output',
'verbose',args)
135 form +=
htmlSubmit(
'Plot',
'doplot', attr =
'class="submit"')
138 page =
htmlForm(form, attr=
'class="params"')
142 page += escape(
str(args))
149 ms = 1000.*(t-floor(t))
150 varName = args.get(
'varName',
'all')
151 baseName =
'beamspot-%s-%s' % (args[
'plotType'], varName)
152 baseName = time.strftime(baseName+
'-%Y%m%d-%H%M%S',time.localtime())
153 baseName +=
'%03i' % ms
157 cmd +=
' -f %s/%s' % (ntDir,args[
'nt'])
158 cmd +=
' -o %s/tmp/%s.gif,%s/tmp/%s.eps,%s/tmp/%s.pdf' % (self.globalConfig[
'wwwDir'],baseName,
159 self.globalConfig[
'wwwDir'],baseName,
160 self.globalConfig[
'wwwDir'],baseName)
161 if args.get(
'project'):
163 selPeriodList = args[
'period']
if isinstance(args[
'period'],list)
else [args[
'period']]
164 selPeriodString =
','.
join([args[
'project']+
'.'+p
for p
in selPeriodList])
165 cmd +=
' --perioddef %s --period %s' % (periodDir,selPeriodString)
166 if args.get(
'fillnr'):
168 cmd +=
' --fill %i' %
int(args[
'fillnr'])
170 return page+
error(
'Fill number must be an integer')
171 if args.get(
'runnr'):
173 cmd +=
' --run %i' %
int(args[
'runnr'])
175 return page+
error(
'Run number must be an integer')
176 if not 'lbaxis' in args:
182 if args.get(
'yscale',
'')!=
'':
184 dummy =
float(args[
'yscale'])
185 cmd +=
' --yscale %s' % args[
'yscale']
187 return page+
error(
'y axis scale expansion factor must be a number')
188 if args.get(
'ymin',
'')!=
'':
190 dummy =
float(args[
'ymin'])
191 cmd +=
' --ymin %s' % args[
'ymin']
193 return page+
error(
'y axis minimum must be a number')
194 if args.get(
'ymax',
'')!=
'':
196 dummy =
float(args[
'ymax'])
197 cmd +=
' --ymax %s' % args[
'ymax']
199 return page+
error(
'y axis maximum must be a number')
200 if args.get(
'xmin',
'')!=
'':
202 dummy =
float(args[
'xmin'])
203 cmd +=
' --xmin %s' % args[
'xmin']
205 return page+
error(
'x axis minimum must be a number')
206 if args.get(
'xmax',
'')!=
'':
208 dummy =
float(args[
'xmax'])
209 cmd +=
' --xmax %s' % args[
'xmax']
211 return page+
error(
'x axis maximum must be a number')
212 if args[
'plotType']==
'summary':
215 cmd +=
' %s %s' % (args[
'plotType'], args[
'varName'])
216 (status,output) = subprocess.getstatusoutput(cmd)
220 imageUrl =
'%s/tmp/%s.gif' % (self.globalConfig.baseUrl,baseName)
221 epsUrl =
'%s/tmp/%s.eps' % (self.globalConfig.baseUrl,baseName)
222 pdfUrl =
'%s/tmp/%s.pdf' % (self.globalConfig.baseUrl,baseName)
223 page += image % (imageUrl,epsUrl,pdfUrl,imageUrl)
226 if status
or (
'verbose' in args):
227 page += cmdoutput % (escape(cmd),status,escape(output))
◆ footer()
def WebPage.WebPage.footer |
( |
|
self, |
|
|
** |
args |
|
) |
| |
|
inherited |
Generate the footer. Default value comes from self.pageConfig['footer'].
Definition at line 395 of file WebPage.py.
396 """Generate the footer. Default value comes from self.pageConfig['footer']."""
397 return self.pageConfig[
'footer'] % self.pageConfig
◆ header()
def WebPage.WebPage.header |
( |
|
self, |
|
|
** |
args |
|
) |
| |
|
inherited |
Generate the page header. Default value comes from self.pageConfig['header'].
Definition at line 383 of file WebPage.py.
384 """Generate the page header. Default value comes from self.pageConfig['header']."""
385 return self.pageConfig[
'header'] % self.pageConfig
◆ index()
def WebPage.WebPage.index |
( |
|
self, |
|
|
** |
args |
|
) |
| |
|
inherited |
Return the complete page.
Definition at line 324 of file WebPage.py.
324 def index(self, **args):
325 """Return the complete page."""
326 if not self.isConfigured:
330 self.pageConfig[
'timeStamp'] = time.strftime(
'%a %b %d %X %Z %Y')
331 contents = self.content(**args)
333 s = startPage % self.pageConfig
334 s = s +
htmlDiv(
'header', self.header(**args),
335 keepEmptyDiv=self.pageConfig[
'keepEmptyHeader'])
336 s = s +
htmlDiv(
'navigation', self.navigation(**args),
337 keepEmptyDiv=self.pageConfig[
'keepEmptyNavigation'])
338 s = s +
htmlDiv(
'content', contents,
339 keepEmptyDiv=self.pageConfig[
'keepEmptyContent'])
340 s = s +
htmlDiv(
'footer', self.footer(**args),
341 keepEmptyDiv=self.pageConfig[
'keepEmptyFooter'])
◆ navigation()
def WebPage.WebPage.navigation |
( |
|
self, |
|
|
** |
args |
|
) |
| |
|
inherited |
Generate the navigation bar. Default value comes from self.pageConfig['navigation'].
Definition at line 387 of file WebPage.py.
387 def navigation(self, **args):
388 """Generate the navigation bar. Default value comes from self.pageConfig['navigation']."""
389 return self.pageConfig[
'navigation'] % self.pageConfig
◆ override()
def WebPage.WebPage.override |
( |
|
self | ) |
|
|
inherited |
Override provides a hook where code to generate or redirect to an alternative
page can be placed by derived classes. If not override of the normal page is
desired, override should return None. Otherwise it should either raise an
appropriate exception or return a string containing the complete alternate page
to display.
Definition at line 375 of file WebPage.py.
376 """Override provides a hook where code to generate or redirect to an alternative
377 page can be placed by derived classes. If not override of the normal page is
378 desired, override should return None. Otherwise it should either raise an
379 appropriate exception or return a string containing the complete alternate page
◆ pageName()
def WebPage.WebPage.pageName |
( |
|
self | ) |
|
|
inherited |
Short cut to retrieve the name (the last element in the URL)
of the current page. This works only if the page has been
added into the page tree using addPage.
Definition at line 294 of file WebPage.py.
295 """Short cut to retrieve the name (the last element in the URL)
296 of the current page. This works only if the page has been
297 added into the page tree using addPage."""
298 return self.pageConfig[
'pageName']
◆ exposed
◆ globalConfig
WebPage.WebPage.globalConfig |
|
inherited |
◆ isConfigured
WebPage.WebPage.isConfigured |
|
inherited |
◆ pageConfig
WebPage.WebPage.pageConfig |
|
inherited |
The documentation for this class was generated from the following file:
def htmlForm(contents, action='', method='post', attr='')
bool configure(asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > &tool, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronEffToolsHandles, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronSFToolsHandles, ToolHandleArray< CP::IMuonTriggerScaleFactors > &muonToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonEffToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonSFToolsHandles, const std::string &triggers, const std::map< std::string, std::string > &legsPerTool, unsigned long nToys, bool debug)
def htmlPara(text='', attr='', escapeText=False)
def addLink(l)
When https is found in a character line, add a link in html If none, simply return the line unchanged...
def htmlTextInput(labelText, parName, args, size=None, maxLength=None, labelAttr='', attr='')
def htmlCheckbox(labelText, parName, args, labelAttr='', attr='')
def htmlDiv(id, contents='', attr='', keepEmptyDiv=True)
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
std::string join(const std::vector< std::string > &v, const char c=',')
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
def htmlSelect(labelText, parName, args, choiceList, hint=None, descriptionSeparator='::', labelAttr='', attr='')
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
def htmlSubmit(text, parName, attr='', onlyOnce=False)