zephir.monitor.agentmanager.templates.AgentPageTmpl

Package zephir :: Package monitor :: Package agentmanager :: Package templates :: Module AgentPageTmpl |
[frames] | no frames]

# Source Code for Module zephir.monitor.agentmanager.templates.AgentPageTmpl

      1  #!/usr/bin/env python
      2
      3
      4
      5
      6  ##################################################
      7  ## DEPENDENCIES
      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 import status
     25
     26  ##################################################
     27  ## MODULE CONSTANTS
     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.616971
     39  __CHEETAH_genTimestamp__ = 'Tue Jan  7 14:14:48 2014'
     40  __CHEETAH_src__ = 'AgentPageTmpl.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  ## CLASSES
     52
     53 -class AgentPageTmpl(PageTmpl):
     54
     55      ##################################################
     56      ## CHEETAH GENERATED METHODS
     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          ## CHEETAH: main method generated for this template
     75          if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
     76              trans = self.transaction # is None unless self.awake() was called
     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          ## START - generated method body
     87
     88          write('''<!-- AgentPageTmpl #encoding utf-8 -->
     89
     90  ''')
     91          _v = VFFSL(SL,"head",False)(VFFSL(SL,"agent.name",True) + " &ndash; " + VFFSL(SL,"hostname",True)) # '$head($agent.name + " &ndash; " + $hostname)' on line 5, col 1
     92          if _v is not None: write(_filter(_v, rawExpr='$head($agent.name + " &ndash; " + $hostname)')) # from line 5, col 1.
     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  ''')
    105          if VFFSL(SL,"agent.description",True) is not None and VFFSL(SL,"len",False)(VFFSL(SL,"agent.description",True)) != 0: # generated from line 16, col 1
    106              write('''<h1 id="title">''')
    107              _v = VFFSL(SL,"agent.description",True) # '$agent.description' on line 17, col 16
    108              if _v is not None: write(_filter(_v, rawExpr='$agent.description')) # from line 17, col 16.
    109              write('''</h1>
    110  ''')
    111          else: # generated from line 18, col 1
    112              write('''<h1 id="title">''')
    113              _v = VFFSL(SL,"agent.name",True) # '$agent.name' on line 19, col 16
    114              if _v is not None: write(_filter(_v, rawExpr='$agent.name')) # from line 19, col 16.
    115              write('''</h1>
    116  ''')
    117          write('''
    118  <div id="nav">
    119    <!-- FIXME need to get that from AgentResource
    120  ''')
    121          siblings = []
    122          section = ""
    123          if VFFSL(SL,"len",False)(VFFSL(SL,"siblings",True)) != 0: # generated from line 26, col 3
    124              write('''  Section ''')
    125              _v = VFFSL(SL,"section",True) # '$section' on line 27, col 11
    126              if _v is not None: write(_filter(_v, rawExpr='$section')) # from line 27, col 11.
    127              write(''' :
    128  ''')
    129          write('''   -->
    130    <ol>
    131  ''')
    132          if VFFSL(SL,"show_clients",True) == True: # generated from line 31, col 5
    133              write('''      <li><a href="/agents/">Clients</a></li>
    134  ''')
    135          write('''    <li><a href="/agents/''')
    136          _v = VFFSL(SL,"host",True) # '$host' on line 34, col 26
    137          if _v is not None: write(_filter(_v, rawExpr='$host')) # from line 34, col 26.
    138          write('''/">Retour</a></li>
    139  ''')
    140          for a in VFFSL(SL,"siblings",True): # generated from line 35, col 2
    141              write('''    <li><a href="./''')
    142              _v = VFFSL(SL,"a",True) # '$a' on line 36, col 20
    143              if _v is not None: write(_filter(_v, rawExpr='$a')) # from line 36, col 20.
    144              write('''/">''')
    145              _v = VFFSL(SL,"a",True) # '$a' on line 36, col 25
    146              if _v is not None: write(_filter(_v, rawExpr='$a')) # from line 36, col 25.
    147              write('''</a></li>
    148  ''')
    149          write('''  </ol>
    150  </div> <!-- nav -->
    151
    152  <div id="side">
    153      <div class="right_status">
    154  ''')
    155          if VFFSL(SL,"agent.name",True) == "bilan": # generated from line 43, col 7
    156              write('''        <img src="./status_long.png"/>
    157  ''')
    158          else: # generated from line 45, col 7
    159              write('''        <img src="./status.png"/>
    160  ''')
    161          write('''    </div>
    162      <div class="left_status">
    163  ''')
    164          s = VFFSL(SL,"agent.last_status",True)
    165          max = VFFSL(SL,"agent.max_status",True)
    166          write('''\t    \xc3\x89tat&nbsp;:&nbsp;<span class="status-''')
    167          _v = VFFSL(SL,"s.level",True) # '$s.level' on line 52, col 44
    168          if _v is not None: write(_filter(_v, rawExpr='$s.level')) # from line 52, col 44.
    169          write('''">''')
    170          _v = VFFSL(SL,"str",False)(VFFSL(SL,"s",True)) # '$str($s)' on line 52, col 54
    171          if _v is not None: write(_filter(_v, rawExpr='$str($s)')) # from line 52, col 54.
    172          write('''</span><br/>
    173  \t    Date de la mesure&nbsp;:&nbsp;''')
    174          _v = VFFSL(SL,"agent.last_measure_date",True) # '$agent.last_measure_date' on line 53, col 36
    175          if _v is not None: write(_filter(_v, rawExpr='$agent.last_measure_date')) # from line 53, col 36.
    176          write('''<br/>
    177  ''')
    178          if VFFSL(SL,"max",True) != VFN(VFFSL(SL,"status",True),"Unknown",False)(): # generated from line 55, col 6
    179              write('''              Dernier probl\xc3\xa8me&nbsp;(<span class="status-''')
    180              _v = VFFSL(SL,"max.level",True) # '$max.level' on line 56, col 59
    181              if _v is not None: write(_filter(_v, rawExpr='$max.level')) # from line 56, col 59.
    182              write('''">''')
    183              _v = VFFSL(SL,"str",False)(VFFSL(SL,"max",True)) # '$str($max)' on line 56, col 71
    184              if _v is not None: write(_filter(_v, rawExpr='$str($max)')) # from line 56, col 71.
    185              write('''</span>)&nbsp;:&nbsp;''')
    186              _v = VFFSL(SL,"agent.max_status_date",True) # '$agent.max_status_date' on line 56, col 102
    187              if _v is not None: write(_filter(_v, rawExpr='$agent.max_status_date')) # from line 56, col 102.
    188              write('''<br/>
    189  ''')
    190          else: # generated from line 57, col 13
    191              write('''              Aucun probl\xc3\xa8me d\xc3\xa9tect\xc3\xa9<br/>
    192  ''')
    193          write('''\t    Intervalle de mesure&nbsp;:&nbsp;''')
    194          _v = VFFSL(SL,"str",False)(VFFSL(SL,"agent.period",True)) # '$str($agent.period)' on line 60, col 39
    195          if _v is not None: write(_filter(_v, rawExpr='$str($agent.period)')) # from line 60, col 39.
    196          write(''' s
    197      </div>
    198
    199  ''')
    200          if VFFSL(SL,"agent.description",True) is not None and VFFSL(SL,"len",False)(VFFSL(SL,"agent.description",True)) != 0: # generated from line 63, col 3
    201              write('''  <!--<p>''')
    202              _v = VFFSL(SL,"agent.description",True) # '$agent.description' on line 64, col 10
    203              if _v is not None: write(_filter(_v, rawExpr='$agent.description')) # from line 64, col 10.
    204              write('''</p>-->
    205  ''')
    206          write('''</div> <!-- side -->
    207
    208  <div id="content">
    209  ''')
    210          for d in VFFSL(SL,"agent.data",True): # generated from line 69, col 1
    211              t = VFFSL(SL,"template_mapping",True)[VFFSL(SL,"d.__class__",True)]()
    212              t.data = VFFSL(SL,"d",True)
    213              write('''  ''')
    214              _v = VFFSL(SL,"str",False)(VFFSL(SL,"t",True)) # '$str($t)' on line 72, col 3
    215              if _v is not None: write(_filter(_v, rawExpr='$str($t)')) # from line 72, col 3.
    216              write('''
    217  ''')
    218          write('''</div> <!-- content -->
    219
    220  ''')
    221          _v = VFFSL(SL,"foot",False)() # '$foot()' on line 76, col 1
    222          if _v is not None: write(_filter(_v, rawExpr='$foot()')) # from line 76, col 1.
    223          write('''
    224  ''')
    225
    226          ########################################
    227          ## END - generated method body
    228
    229          return _dummyTrans and trans.response().getvalue() or ""
    230
    231      ##################################################
    232      ## CHEETAH GENERATED ATTRIBUTES
    233
    234
    235      _CHEETAH__instanceInitialized = False
    236
    237      _CHEETAH_version = __CHEETAH_version__
    238
    239      _CHEETAH_versionTuple = __CHEETAH_versionTuple__
    240
    241      _CHEETAH_genTime = __CHEETAH_genTime__
    242
    243      _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
    244
    245      _CHEETAH_src = __CHEETAH_src__
    246
    247      _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
    248
    249      _mainCheetahMethod_for_AgentPageTmpl= 'respond'
    250
    251  ## END CLASS DEFINITION
    252
    253  if not hasattr(AgentPageTmpl, '_initCheetahAttributes'):
    254      templateAPIClass = getattr(AgentPageTmpl, '_CHEETAH_templateClass', Template)
    255      templateAPIClass._addCheetahPlumbingCodeToClass(AgentPageTmpl)
    256
    257
    258  # CHEETAH was developed by Tavis Rudd and Mike Orr
    259  # with code, advice and input from many other volunteers.
    260  # For more information visit http://www.CheetahTemplate.org/
    261
    262  ##################################################
    263  ## if run from command line:
    264  if __name__ == '__main__':
    265      from Cheetah.TemplateCmdLineIface import CmdLineIface
    266      CmdLineIface(templateObj=AgentPageTmpl()).run()
    267