1
2
3
4
5
6
7
8 import sys
9 import os
10 import os.path
11 from os.path import getmtime, exists
12 import time
13 import types
14 import __builtin__
15 from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
16 from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
17 from Cheetah.Template import Template
18 from Cheetah.DummyTransaction import DummyTransaction
19 from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
20 from Cheetah.CacheRegion import CacheRegion
21 import Cheetah.Filters as Filters
22 import Cheetah.ErrorCatchers as ErrorCatchers
23 from zephir.monitor.agentmanager.templates.PageTmpl import PageTmpl
24 from zephir.monitor.agentmanager.templates.SectionTmpl import SectionTmpl
25
26
27
28 try:
29 True, False
30 except NameError:
31 True, False = (1==1), (1==0)
32 VFFSL=valueFromFrameOrSearchList
33 VFSL=valueFromSearchList
34 VFN=valueForName
35 currentTime=time.time
36 __CHEETAH_version__ = '2.0.1'
37 __CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
38 __CHEETAH_genTime__ = 1389100488.77145
39 __CHEETAH_genTimestamp__ = 'Tue Jan 7 14:14:48 2014'
40 __CHEETAH_src__ = 'ManagerPageTmpl.tmpl'
41 __CHEETAH_srcLastModified__ = 'Tue Jan 7 14:06:55 2014'
42 __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
43
44 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
45 raise AssertionError(
46 'This template was compiled with Cheetah version'
47 ' %s. Templates compiled before version %s must be recompiled.'%(
48 __CHEETAH_version__, RequiredCheetahVersion))
49
50
51
52
53 -class ManagerPageTmpl(PageTmpl):
54
55
56
57
58
59 - def __init__(self, *args, **KWs):
60
61 PageTmpl.__init__(self, *args, **KWs)
62 if not self._CHEETAH__instanceInitialized:
63 cheetahKWArgs = {}
64 allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
65 for k,v in KWs.items():
66 if k in allowedKWs: cheetahKWArgs[k] = v
67 self._initCheetahInstance(**cheetahKWArgs)
68
69
70 - def respond(self, trans=None):
71
72
73
74
75 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
76 trans = self.transaction
77 if not trans:
78 trans = DummyTransaction()
79 _dummyTrans = True
80 else: _dummyTrans = False
81 write = trans.response().write
82 SL = self._CHEETAH__searchList
83 _filter = self._CHEETAH__currentFilter
84
85
86
87
88 write('''<!-- ManagerPageTmpl #encoding utf-8 -->
89
90 ''')
91 _v = VFFSL(SL,"head",False)("ZStats - " + VFFSL(SL,"hostname",True))
92 if _v is not None: write(_filter(_v, rawExpr='$head("ZStats - " + $hostname)'))
93 write('''
94
95 <SCRIPT LANGUAGE="JavaScript">
96 <!--
97 function clear() {
98 location.reload(false)
99 }
100 setTimeout ("clear()", 60000);
101 // -->
102 </SCRIPT>
103
104 <h1 id="title">''')
105 _v = VFFSL(SL,"description",True)
106 if _v is not None: write(_filter(_v, rawExpr='$description'))
107 write('''</h1>
108
109 <div id="nav">
110 ''')
111 if VFFSL(SL,"len",False)(VFFSL(SL,"manager.structure",True)) != 0:
112 write(''' <ol>
113 ''')
114 if VFFSL(SL,"show_clients",True) == True:
115 write(''' <li><a href="/agents/">Clients</a></li>
116 ''')
117 for section, agents in VFFSL(SL,"manager.structure",True):
118 write(''' <li><a href="#''')
119 _v = VFFSL(SL,"section",True)
120 if _v is not None: write(_filter(_v, rawExpr='$section'))
121 write('''">''')
122 _v = VFFSL(SL,"section",True)
123 if _v is not None: write(_filter(_v, rawExpr='$section'))
124 write('''</a></li>
125 ''')
126 write(''' <li><a href="/agents/''')
127 _v = VFFSL(SL,"manager.client_name",True)
128 if _v is not None: write(_filter(_v, rawExpr='$manager.client_name'))
129 write('''/bilan/">Bilan Mensuel</a></li>
130 </ol>
131 ''')
132 write('''</div> <!-- nav -->
133
134 <div id="content">
135 ''')
136 t = SectionTmpl()
137 t.depth = 2
138 t.content = VFFSL(SL,"manager.structure",True)
139 t.manager = VFFSL(SL,"manager",True)
140 _v = VFFSL(SL,"str",False)(VFFSL(SL,"t",True))
141 if _v is not None: write(_filter(_v, rawExpr='$str($t)'))
142 write('''
143 </div> <!-- content -->
144
145 ''')
146 _v = VFFSL(SL,"foot",False)()
147 if _v is not None: write(_filter(_v, rawExpr='$foot()'))
148 write('''
149 ''')
150
151
152
153
154 return _dummyTrans and trans.response().getvalue() or ""
155
156
157
158
159
160 _CHEETAH__instanceInitialized = False
161
162 _CHEETAH_version = __CHEETAH_version__
163
164 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
165
166 _CHEETAH_genTime = __CHEETAH_genTime__
167
168 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
169
170 _CHEETAH_src = __CHEETAH_src__
171
172 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
173
174 _mainCheetahMethod_for_ManagerPageTmpl= 'respond'
175
176
177
178 if not hasattr(ManagerPageTmpl, '_initCheetahAttributes'):
179 templateAPIClass = getattr(ManagerPageTmpl, '_CHEETAH_templateClass', Template)
180 templateAPIClass._addCheetahPlumbingCodeToClass(ManagerPageTmpl)
181
182
183
184
185
186
187
188
189 if __name__ == '__main__':
190 from Cheetah.TemplateCmdLineIface import CmdLineIface
191 CmdLineIface(templateObj=ManagerPageTmpl()).run()
192