#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
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
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1313541191.954781
__CHEETAH_genTimestamp__ = 'Tue Aug 16 18:33:11 2011'
__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):

        super(HeartbeatListing, self).__init__(*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_55327303 = _filter
        filterName = u'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(u'''
''')
        self._CHEETAH__globalSetVars["cnt"] = 0
        write(u'''
<thead>
<tr>
<td class="filtered_column">
  <div>''')
        if False:
            _("Agent")
        _v = VFFSL(SL,"_",False)("Agent") # u'$_("Agent")' on line 11, col 8
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Agent")')) # from line 11, col 8.
        write(u'''</div>
''')
        if VFFSL(SL,"name_filtered",True): # generated from line 12, col 3
            write(u'''    <span>*</span>
''')
        write(u'''</td>

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

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

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

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

</thead>
''')
        _filter = self._CHEETAH__currentFilter = _orig_filter_55327303
        
        ########################################
        ## 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(u'''
<td>
  <a class="popup_menu_toggle" href="#">''')
        _v = VFFSL(SL,"message.agent.value",True) # u'$message.agent.value' on line 49, col 41
        if _v is not None: write(_filter(_v, rawExpr=u'$message.agent.value')) # from line 49, col 41.
        write(u'''</a>
  <span class="popup_menu">
   - <a href="''')
        _v = VFFSL(SL,"message.summary",True) # u'$message.summary' on line 51, col 15
        if _v is not None: write(_filter(_v, rawExpr=u'$message.summary')) # from line 51, col 15.
        write(u'''">''')
        if False:
            _("Heartbeat summary")
        _v = VFFSL(SL,"_",False)("Heartbeat summary") # u'$_("Heartbeat summary")' on line 51, col 33
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Heartbeat summary")')) # from line 51, col 33.
        write(u'''</a><br />
   - <a href="''')
        _v = VFFSL(SL,"message.agent.inline_filter",True) # u'$message.agent.inline_filter' on line 52, col 15
        if _v is not None: write(_filter(_v, rawExpr=u'$message.agent.inline_filter')) # from line 52, col 15.
        write(u'''">''')
        if False:
            _("Filter on agent")
        _v = VFFSL(SL,"_",False)("Filter on agent") # u'$_("Filter on agent")' on line 52, col 45
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Filter on agent")')) # from line 52, col 45.
        write(u'''</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(u'''    <a class="popup_menu_toggle" href="#">''')
                _v = VFFSL(SL,"address.value",True) # u'$address.value' on line 59, col 43
                if _v is not None: write(_filter(_v, rawExpr=u'$address.value')) # from line 59, col 43.
                write(u'''</a>
    <span class="popup_menu">
      - <a href="''')
                _v = VFFSL(SL,"address.inline_filter",True) # u'$address.inline_filter' on line 61, col 18
                if _v is not None: write(_filter(_v, rawExpr=u'$address.inline_filter')) # from line 61, col 18.
                write(u'''">''')
                if False:
                    _("Filter on address")
                _v = VFFSL(SL,"_",False)("Filter on address") # u'$_("Filter on address")' on line 61, col 42
                if _v is not None: write(_filter(_v, rawExpr=u'$_("Filter on address")')) # from line 61, col 42.
                write(u'''</a><br />
      - <a target="''')
                _v = VFFSL(SL,"prewikka.external_link_target",True) # u'$prewikka.external_link_target' on line 62, col 20
                if _v is not None: write(_filter(_v, rawExpr=u'$prewikka.external_link_target')) # from line 62, col 20.
                write(u'''" href="https://www.prelude-ids.com/host_details.php?host=''')
                _v = VFFSL(SL,"address.value",True) # u'$address.value' on line 62, col 108
                if _v is not None: write(_filter(_v, rawExpr=u'$address.value')) # from line 62, col 108.
                write(u'''">Address information</a><br />
''')
                for name, link in VFFSL(SL,"address.host_commands",True): # generated from line 63, col 7
                    write(u'''      - <a href="''')
                    _v = VFFSL(SL,"link",True) # u'$link' on line 64, col 18
                    if _v is not None: write(_filter(_v, rawExpr=u'$link')) # from line 64, col 18.
                    write(u'''">''')
                    _v = VFFSL(SL,"name",True) # u'$name' on line 64, col 25
                    if _v is not None: write(_filter(_v, rawExpr=u'$name')) # from line 64, col 25.
                    write(u'''</a><br />
''')
                write(u'''    </span>
    <br />
''')
        else: # generated from line 69, col 3
            write(u'''    n/a
''')
        write(u'''</td>

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

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

<td>''')
        _v = VFFSL(SL,"message.time.value",True) # u'$message.time.value' on line 82, col 5
        if _v is not None: write(_filter(_v, rawExpr=u'$message.time.value')) # from line 82, col 5.
        write(u'''</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(u'''
''')
        self.message_fields_header(trans=trans)
        write(u'''
''')
        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()


