#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
from os.path import getmtime, exists
import time
import types
import __builtin__
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import DummyTransaction
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from prewikka.templates.MessageListing import MessageListing

##################################################
## MODULE CONSTANTS
try:
    True, False
except NameError:
    True, False = (1==1), (1==0)
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.0.1'
__CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
__CHEETAH_genTime__ = 1268222107.2801149
__CHEETAH_genTimestamp__ = 'Wed Mar 10 04:55:07 2010'
__CHEETAH_src__ = 'prewikka/templates/HeartbeatListing.tmpl'
__CHEETAH_srcLastModified__ = 'Tue May  5 08:55:59 2009'
__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class HeartbeatListing(MessageListing):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        MessageListing.__init__(self, *args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def message_fields_header(self, **KWS):



        ## CHEETAH: generated from #block message_fields_header at line 3, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        _orig_filter_28096021 = _filter
        filterName = 'CleanOutput'
        if self._CHEETAH__filters.has_key("CleanOutput"):
            _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
        else:
            _filter = self._CHEETAH__currentFilter = \
			self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
        write('''
''')
        self._CHEETAH__globalSetVars["cnt"] = 0
        write('''
<thead>
<tr>
<td class="filtered_column">
  <div>''')
        if False:
            _("Agent")
        _v = VFFSL(SL,"_",False)("Agent") # '$_("Agent")' on line 11, col 8
        if _v is not None: write(_filter(_v, rawExpr='$_("Agent")')) # from line 11, col 8.
        write('''</div>
''')
        if VFFSL(SL,"name_filtered",True): # generated from line 12, col 3
            write('''    <span>*</span>
''')
        write('''</td>

<td class="filtered_column">
  <div>''')
        if False:
            _("Node address")
        _v = VFFSL(SL,"_",False)("Node address") # '$_("Node address")' on line 18, col 8
        if _v is not None: write(_filter(_v, rawExpr='$_("Node address")')) # from line 18, col 8.
        write('''</div>
''')
        if VFFSL(SL,"address_filtered",True): # generated from line 19, col 3
            write('''    <span>*</span>
''')
        write('''</td>

<td class="filtered_column">
  <div>''')
        if False:
            _("Node name")
        _v = VFFSL(SL,"_",False)("Node name") # '$_("Node name")' on line 25, col 8
        if _v is not None: write(_filter(_v, rawExpr='$_("Node name")')) # from line 25, col 8.
        write('''</div>
''')
        if VFFSL(SL,"node_name_filtered",True): # generated from line 26, col 3
            write('''    <span>*</span>
''')
        write('''</td>

<td class="filtered_column">
  <div>''')
        if False:
            _("Model")
        _v = VFFSL(SL,"_",False)("Model") # '$_("Model")' on line 32, col 8
        if _v is not None: write(_filter(_v, rawExpr='$_("Model")')) # from line 32, col 8.
        write('''</div>
''')
        if VFFSL(SL,"model_filtered",True): # generated from line 33, col 3
            write('''    <span>*</span>
''')
        write('''</td>

<td>''')
        if False:
            _("Time")
        _v = VFFSL(SL,"_",False)("Time") # '$_("Time")' on line 38, col 5
        if _v is not None: write(_filter(_v, rawExpr='$_("Time")')) # from line 38, col 5.
        write('''</td>
<td>&nbsp;</td>
</tr>

</thead>
''')
        _filter = self._CHEETAH__currentFilter = _orig_filter_28096021
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def message_fields(self, **KWS):



        ## CHEETAH: generated from #block message_fields at line 46, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write('''
<td>
  <a class="popup_menu_toggle" href="#">''')
        _v = VFFSL(SL,"message.agent.value",True) # '$message.agent.value' on line 49, col 41
        if _v is not None: write(_filter(_v, rawExpr='$message.agent.value')) # from line 49, col 41.
        write('''</a>
  <span class="popup_menu">
   - <a href="''')
        _v = VFFSL(SL,"message.summary",True) # '$message.summary' on line 51, col 15
        if _v is not None: write(_filter(_v, rawExpr='$message.summary')) # from line 51, col 15.
        write('''">''')
        if False:
            _("Heartbeat summary")
        _v = VFFSL(SL,"_",False)("Heartbeat summary") # '$_("Heartbeat summary")' on line 51, col 33
        if _v is not None: write(_filter(_v, rawExpr='$_("Heartbeat summary")')) # from line 51, col 33.
        write('''</a><br />
   - <a href="''')
        _v = VFFSL(SL,"message.agent.inline_filter",True) # '$message.agent.inline_filter' on line 52, col 15
        if _v is not None: write(_filter(_v, rawExpr='$message.agent.inline_filter')) # from line 52, col 15.
        write('''">''')
        if False:
            _("Filter on agent")
        _v = VFFSL(SL,"_",False)("Filter on agent") # '$_("Filter on agent")' on line 52, col 45
        if _v is not None: write(_filter(_v, rawExpr='$_("Filter on agent")')) # from line 52, col 45.
        write('''</a>
  </span>
</td>

<td>
''')
        if len(VFFSL(SL,"message.node_addresses",True)) > 0: # generated from line 57, col 3
            for address in VFFSL(SL,"message.node_addresses",True): # generated from line 58, col 5
                write('''    <a class="popup_menu_toggle" href="#">''')
                _v = VFFSL(SL,"address.value",True) # '$address.value' on line 59, col 43
                if _v is not None: write(_filter(_v, rawExpr='$address.value')) # from line 59, col 43.
                write('''</a>
    <span class="popup_menu">
      - <a href="''')
                _v = VFFSL(SL,"address.inline_filter",True) # '$address.inline_filter' on line 61, col 18
                if _v is not None: write(_filter(_v, rawExpr='$address.inline_filter')) # from line 61, col 18.
                write('''">''')
                if False:
                    _("Filter on address")
                _v = VFFSL(SL,"_",False)("Filter on address") # '$_("Filter on address")' on line 61, col 42
                if _v is not None: write(_filter(_v, rawExpr='$_("Filter on address")')) # from line 61, col 42.
                write('''</a><br />
      - <a target="''')
                _v = VFFSL(SL,"prewikka.external_link_target",True) # '$prewikka.external_link_target' on line 62, col 20
                if _v is not None: write(_filter(_v, rawExpr='$prewikka.external_link_target')) # from line 62, col 20.
                write('''" href="https://www.prelude-ids.com/host_details.php?host=''')
                _v = VFFSL(SL,"address.value",True) # '$address.value' on line 62, col 108
                if _v is not None: write(_filter(_v, rawExpr='$address.value')) # from line 62, col 108.
                write('''">Address information</a><br />
''')
                for name, link in VFFSL(SL,"address.host_commands",True): # generated from line 63, col 7
                    write('''      - <a href="''')
                    _v = VFFSL(SL,"link",True) # '$link' on line 64, col 18
                    if _v is not None: write(_filter(_v, rawExpr='$link')) # from line 64, col 18.
                    write('''">''')
                    _v = VFFSL(SL,"name",True) # '$name' on line 64, col 25
                    if _v is not None: write(_filter(_v, rawExpr='$name')) # from line 64, col 25.
                    write('''</a><br />
''')
                write('''    </span>
    <br />
''')
        else: # generated from line 69, col 3
            write('''    n/a
''')
        write('''</td>

<td>
 <a href="''')
        _v = VFFSL(SL,"message.node_name.inline_filter",True) # '$message.node_name.inline_filter' on line 75, col 11
        if _v is not None: write(_filter(_v, rawExpr='$message.node_name.inline_filter')) # from line 75, col 11.
        write('''">''')
        _v = VFFSL(SL,"message.node_name.value",True) # '$message.node_name.value' on line 75, col 45
        if _v is not None: write(_filter(_v, rawExpr='$message.node_name.value')) # from line 75, col 45.
        write('''</a><br />
</td>

<td>
  <a href="''')
        _v = VFFSL(SL,"message.model.inline_filter",True) # '$message.model.inline_filter' on line 79, col 12
        if _v is not None: write(_filter(_v, rawExpr='$message.model.inline_filter')) # from line 79, col 12.
        write('''">''')
        _v = VFFSL(SL,"message.model.value",True) # '$message.model.value' on line 79, col 42
        if _v is not None: write(_filter(_v, rawExpr='$message.model.value')) # from line 79, col 42.
        write('''</a>
</td>

<td>''')
        _v = VFFSL(SL,"message.time.value",True) # '$message.time.value' on line 82, col 5
        if _v is not None: write(_filter(_v, rawExpr='$message.time.value')) # from line 82, col 5.
        write('''</td>

''')
        self._CHEETAH__globalSetVars["cnt"] += 1
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def writeBody(self, **KWS):



        ## CHEETAH: main method generated for this template
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write('''
''')
        self.message_fields_header(trans=trans)
        write('''
''')
        self.message_fields(trans=trans)
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    _mainCheetahMethod_for_HeartbeatListing= 'writeBody'

## END CLASS DEFINITION

if not hasattr(HeartbeatListing, '_initCheetahAttributes'):
    templateAPIClass = getattr(HeartbeatListing, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(HeartbeatListing)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=HeartbeatListing()).run()


