ATLAS Offline Software
index.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 """
4 ATLAS Beam Spot web page. This is the root page that sets up the tree of beam spot
5 web pages. This is intended to be run by CherryPy through Apache's mod_python, but
6 you can test it locally using `python index.py`.
7 
8 Sample Apache configuration:
9 
10 <Location "/">
11  PythonPath "sys.path+['/home/jb/atl/InDetBeamSpotExample/www']"
12  SetHandler python-program
13  PythonHandler cherrypy._cpmodpy::handler
14  PythonOption cherrypy.setup index::setup_server
15  PythonDebug On
16 </Location>
17 """
18 
19 __author__ = 'Juerg Beringer'
20 __version__ = 'index.py atlas/athena'
21 
22 import os
23 import cherrypy
24 
25 from BeamSpotWebPage import BeamSpotWebPage, DummyPage
26 from BeamSpotSummary import BeamSpotSummary
27 from JobBrowser import JobBrowser
28 from JobDetails import JobDetails
29 from FileBrowser import FileBrowser
30 from PlotServer import PlotServer
31 from MyPlots import MyPlots
32 from WebPlots import WebPlots
33 from DebugPage import DebugPage
34 
35 
36 # Application configuration
37 currentDir = os.path.dirname(os.path.abspath(__file__))
38 beamSpotConfig = {
39  '/': { 'tools.staticdir.root': currentDir},
40  '/css': { 'tools.staticdir.on': True,
41  'tools.staticdir.dir': 'css'},
42  '/js': { 'tools.staticdir.on': True,
43  'tools.staticdir.dir': 'js'},
44  '/images': { 'tools.staticdir.on': True,
45  'tools.staticdir.dir': 'images'},
46  '/tmp': { 'tools.staticdir.on': True,
47  'tools.staticdir.dir': 'tmp'}
48 }
49 
50 
51 # Root page configuration
53 root.globalConfig.baseUrl = '/webapp'
54 
55 root.globalConfig['jobDir'] = os.environ.get('JOBDIR', '/afs/cern.ch/user/a/atlidbs/jobs')
56 root.globalConfig['taskDb'] = os.environ.get('TASKDB', 'auth_file:/afs/cern.ch/user/a/atlidbs/private/beamspotdbinfo_r.dat')
57 root.globalConfig['wwwDir'] = os.environ.get('WWWDIR', '/var/vhost/atlas-beamspot/secure/InDetBeamSpotExample/www')
58 root.globalConfig['ntDir'] = os.environ.get('NTDIR', '/afs/cern.ch/user/a/atlidbs/nt')
59 root.globalConfig['periodDir'] = os.environ.get('PERIODDIR','/afs/cern.ch/user/a/atlidbs/nt/DataPeriods')
60 root.globalConfig['webPlotDir'] = os.environ.get('WEBPLOTDIR', '/afs/cern.ch/user/a/atlidbs/nt/webplots')
61 
62 # Local for testing
63 #root.globalConfig['jobDir'] = os.environ.get('JOBDIR', '/data/atlas/jobs/atlidbs')
64 #root.globalConfig['taskDb'] = os.environ.get('TASKDB', 'sqlite_file:'+root.globalConfig['jobDir']+'/taskdata.db')
65 #root.globalConfig['wwwDir'] = os.environ.get('WWWDIR', '/home/jb/ATLAS/BeamSpot/InDetBeamSpotExample/www')
66 #root.globalConfig['ntDir'] = os.environ.get('NTDIR', '/data/atlas/analysis/BeamSpot/nt')
67 #root.globalConfig['periodDir'] = os.environ.get('PERIODDIR','/home/jb/analysis/BeamSpot/nt/DataPeriods')
68 #root.globalConfig['webPlotDir'] = os.environ.get('WEBPLOTDIR', '/data/atlas/analysis/BeamSpot/nt/webplots')
69 
70 # Page tree
71 root.addPage('summary', BeamSpotSummary())
72 root.addPage('t0Summary', BeamSpotSummary(), query='?type=DB_BEAMSPOT')
73 root.addPage('bcidSummary', BeamSpotSummary(), query='?type=BCID&limit=0')
74 root.addPage('reprocSummary', BeamSpotSummary(), query='?type=REPR&limit=0')
75 root.addPage('jobs', JobBrowser())
76 root.addPage('details', JobDetails())
77 root.addPage('files', FileBrowser('/jobfiles'))
78 root.addPage('myplots', MyPlots())
79 root.addPage('plots', PlotServer())
80 root.addPage('webplots',WebPlots())
81 root.addPage('debug', DebugPage())
82 
83 
84 # Setup for mod_python
86  cherrypy.config.update({'environment': 'production',
87  'log.screen': False,
88  'server.socket_host': '127.0.0.1',
89  'log.error_file': '/tmp/site.log',
90  'show_tracebacks': False})
91  cherrypy.tree.mount(root, root.globalConfig.baseUrl, config=beamSpotConfig)
92 
93 
94 # Code to test or run locally
95 if __name__ == '__main__':
96 
97  # For plain CGI
98  #import cgi
99  #import cgitb; cgitb.enable()
100  #p = Root(pageTitle = 'HelloWorld Test', contentType='Content-type: text/html\n\n')
101  #print p.index()
102 
103  # For local CherryPy (run as `python index.py')
104  # NOTE: see http://www.cherrypy.org/wiki/StaticContent on how to
105  # serve static content such as the css file
106  import cherrypy
107  cherrypy.quickstart(root, root.globalConfig.baseUrl, config=beamSpotConfig)
JobBrowser.JobBrowser
Definition: JobBrowser.py:72
MyPlots.MyPlots
Definition: MyPlots.py:57
BeamSpotSummary.BeamSpotSummary
Definition: BeamSpotSummary.py:63
WebPlots.WebPlots
Definition: WebPlots.py:27
DebugPage.DebugPage
Definition: DebugPage.py:41
PlotServer.PlotServer
Definition: PlotServer.py:22
FileBrowser.FileBrowser
Definition: FileBrowser.py:19
index.setup_server
def setup_server()
Definition: index.py:85
JobDetails.JobDetails
Definition: JobDetails.py:53
BeamSpotWebPage.BeamSpotWebPage
Definition: BeamSpotWebPage.py:47