#!/usr/bin/env python
# -*- coding: UTF-8 -*-



##################################################
## 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 MainTemplate import MainTemplate
from nav.web import escape

##################################################
## 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__ = 1225031605.268955
__CHEETAH_genTimestamp__ = 'Sun Oct 26 14:33:25 2008'
__CHEETAH_src__ = 'MachineTrackerTemplate.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Jan 26 14:52:44 2007'
__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 MachineTrackerTemplate(MainTemplate):

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


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

        MainTemplate.__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 tableTitle(self, title, hits, columnCount, **KWS):



        ## CHEETAH: generated from #def tableTitle($title, $hits, $columnCount) at line 121, 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
        
        columnCount += 1
        write('''
<table class="horiztable">
    <caption>
        <span class="cornerkludge"></span>
        ''')
        _v = VFFSL(SL,"title",True) # '$title' on line 127, col 9
        if _v is not None: write(_filter(_v, rawExpr='$title')) # from line 127, col 9.
        write('''<br />
        <span class="subtitle">''')
        _v = VFFSL(SL,"hits",True) # '$hits' on line 128, col 32
        if _v is not None: write(_filter(_v, rawExpr='$hits')) # from line 128, col 32.
        write(''' hits</span>
    </caption>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def tableHeader(self, rowCount, columns, **KWS):



        ## CHEETAH: generated from #def tableHeader($rowCount, $columns) at line 132, 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
        
        rowCount = VFFSL(SL,"rowCount",True) + 1
        write('''    <tr class="header">
        <td class="leftkludge" rowspan="''')
        _v = VFFSL(SL,"rowCount",True) # '$rowCount' on line 135, col 41
        if _v is not None: write(_filter(_v, rawExpr='$rowCount')) # from line 135, col 41.
        write('''"></td>
''')
        for column in VFFSL(SL,"columns",True): # generated from line 136, col 3
            write('''        <th>''')
            _v = VFFSL(SL,"column",True) # '$column' on line 137, col 13
            if _v is not None: write(_filter(_v, rawExpr='$column')) # from line 137, col 13.
            write('''</th>
''')
        write('''        <td class="rightkludge" rowspan="''')
        _v = VFFSL(SL,"rowCount",True) # '$rowCount' on line 139, col 42
        if _v is not None: write(_filter(_v, rawExpr='$rowCount')) # from line 139, col 42.
        write('''"></td>
    </tr>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def arpTable(self, table, **KWS):



        ## CHEETAH: generated from #def arpTable($table) at line 143, 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
        
        if VFFSL(SL,"form.dns",True) == "on": # generated from line 144, col 3
            columns = ('DNS', 'IP', '', 'MAC', 'Start time', 'End time')
        else : # generated from line 146, col 3
            columns = ('IP', '', 'MAC', 'Start time', 'End time')
        columnCount = len(VFFSL(SL,"columns",True))
        write('''
  ''')
        _v = VFFSL(SL,"tableTitle",False)("IP Search results", len(VFFSL(SL,"table",True)), VFFSL(SL,"columnCount",True)) # '$tableTitle("IP Search results", len($table), $columnCount)' on line 151, col 3
        if _v is not None: write(_filter(_v, rawExpr='$tableTitle("IP Search results", len($table), $columnCount)')) # from line 151, col 3.
        write('''
  ''')
        _v = VFFSL(SL,"tableHeader",False)(len(VFFSL(SL,"table",True)), VFFSL(SL,"columns",True)) # '$tableHeader(len($table), $columns)' on line 152, col 3
        if _v is not None: write(_filter(_v, rawExpr='$tableHeader(len($table), $columns)')) # from line 152, col 3.
        write('''

''')
        for row in VFFSL(SL,"table",True): # generated from line 154, col 3
            write('''    <tr class="''')
            _v = VFFSL(SL,"rowcycler",True) # '$rowcycler' on line 155, col 16
            if _v is not None: write(_filter(_v, rawExpr='$rowcycler')) # from line 155, col 16.
            write('''">
''')
            if VFFSL(SL,"form.dns",True)=="on": # generated from line 156, col 5
                write('''        <td>''')
                _v = VFFSL(SL,"row.dnsname",True) # '$row.dnsname' on line 157, col 13
                if _v is not None: write(_filter(_v, rawExpr='$row.dnsname')) # from line 157, col 13.
                write('''</td>
''')
            write('''        <td><a href="ip?from_ip=''')
            _v = VFFSL(SL,"row.ipaddr",True) # '$row.ipaddr' on line 159, col 33
            if _v is not None: write(_filter(_v, rawExpr='$row.ipaddr')) # from line 159, col 33.
            write('''&days=''')
            _v = VFFSL(SL,"form.days",True) # '$form.days' on line 159, col 50
            if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 159, col 50.
            write('''&dns=''')
            _v = VFFSL(SL,"form.dns",True) # '$form.dns' on line 159, col 65
            if _v is not None: write(_filter(_v, rawExpr='$form.dns')) # from line 159, col 65.
            write('''" title="Search again for this IP address">''')
            _v = VFFSL(SL,"row.ipaddr",True) # '$row.ipaddr' on line 159, col 117
            if _v is not None: write(_filter(_v, rawExpr='$row.ipaddr')) # from line 159, col 117.
            write('''</a></td>
\t<td>''')
            if VFFSL(SL,"row.ipaddr",True): # generated from line 161, col 9
                write('''            <a href="/ipinfo/?ip=''')
                _v = VFFSL(SL,"row.ipaddr",True) # '${row.ipaddr}' on line 162, col 34
                if _v is not None: write(_filter(_v, rawExpr='${row.ipaddr}')) # from line 162, col 34.
                write('''" title="Show information about this particular IP address"><img src="''')
                _v = VFFSL(SL,"imagefolder",True) # '$imagefolder' on line 162, col 117
                if _v is not None: write(_filter(_v, rawExpr='$imagefolder')) # from line 162, col 117.
                write('''/arpcam/ipinfolink.png" width="11" height="11" alt="IP Info"></a>
''')
            write('''        </td>
''')
            if type(VFFSL(SL,"row.mac",True)) is str: # generated from line 165, col 9
                macformatted = '%s:%s:%s:%s:%s:%s' % (VFN(VFFSL(SL,"row",True),"mac",True)[0:2],             VFN(VFFSL(SL,"row",True),"mac",True)[2:4], VFN(VFFSL(SL,"row",True),"mac",True)[4:6], VFN(VFFSL(SL,"row",True),"mac",True)[6:8], VFN(VFFSL(SL,"row",True),"mac",True)[8:10],             VFN(VFFSL(SL,"row",True),"mac",True)[10:12])
            else: # generated from line 169, col 9
                macformatted = VFFSL(SL,"row.mac",True)
            write('''\t<td><a href="mac?mac=''')
            _v = VFFSL(SL,"row.mac",True) # '$row.mac' on line 172, col 23
            if _v is not None: write(_filter(_v, rawExpr='$row.mac')) # from line 172, col 23.
            write('''&days=''')
            _v = VFFSL(SL,"form.days",True) # '$form.days' on line 172, col 37
            if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 172, col 37.
            write('''&dns=''')
            _v = VFFSL(SL,"form.dns",True) # '$form.dns' on line 172, col 52
            if _v is not None: write(_filter(_v, rawExpr='$form.dns')) # from line 172, col 52.
            write('''" title="Search for this MAC address">''')
            _v = VFFSL(SL,"macformatted",True) # '$macformatted' on line 172, col 99
            if _v is not None: write(_filter(_v, rawExpr='$macformatted')) # from line 172, col 99.
            write('''</a></td>
        <td>''')
            _v = VFFSL(SL,"row.start_time",True) # '$row.start_time' on line 173, col 13
            if _v is not None: write(_filter(_v, rawExpr='$row.start_time')) # from line 173, col 13.
            write('''</td>
        <td>''')
            _v = VFFSL(SL,"row.end_time",True) # '$row.end_time' on line 174, col 13
            if _v is not None: write(_filter(_v, rawExpr='$row.end_time')) # from line 174, col 13.
            write('''</td>
    </tr>
''')
        write('''</table>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def camTable(self, table, **KWS):



        ## CHEETAH: generated from #def camTable($table) at line 180, 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
        
        columns = ('MAC', 'Switch', 'Module', 'Port', 'Start time', 'End time')
        columnCount = len(VFFSL(SL,"columns",True))
        write('''
  ''')
        _v = VFFSL(SL,"tableTitle",False)("MAC Search results", len(VFFSL(SL,"table",True)), VFFSL(SL,"columnCount",True)) # '$tableTitle("MAC Search results", len($table), $columnCount)' on line 184, col 3
        if _v is not None: write(_filter(_v, rawExpr='$tableTitle("MAC Search results", len($table), $columnCount)')) # from line 184, col 3.
        write('''
  ''')
        _v = VFFSL(SL,"tableHeader",False)(len(VFFSL(SL,"table",True)), VFFSL(SL,"columns",True)) # '$tableHeader(len($table), $columns)' on line 185, col 3
        if _v is not None: write(_filter(_v, rawExpr='$tableHeader(len($table), $columns)')) # from line 185, col 3.
        write('''

''')
        for row in VFFSL(SL,"table",True): # generated from line 187, col 3
            write('''    <tr class="''')
            _v = VFFSL(SL,"rowcycler",True) # '$rowcycler' on line 188, col 16
            if _v is not None: write(_filter(_v, rawExpr='$rowcycler')) # from line 188, col 16.
            write('''">
''')
            if type(VFFSL(SL,"row.mac",True)) is str: # generated from line 189, col 9
                macformatted = '%s:%s:%s:%s:%s:%s' % (VFN(VFFSL(SL,"row",True),"mac",True)[0:2],             VFN(VFFSL(SL,"row",True),"mac",True)[2:4], VFN(VFFSL(SL,"row",True),"mac",True)[4:6], VFN(VFFSL(SL,"row",True),"mac",True)[6:8], VFN(VFFSL(SL,"row",True),"mac",True)[8:10],             VFN(VFFSL(SL,"row",True),"mac",True)[10:12])
            else: # generated from line 193, col 9
                macformatted = VFFSL(SL,"row.mac",True)
            write('''        <td><a href="mac?mac=''')
            _v = VFFSL(SL,"row.mac",True) # '$row.mac' on line 196, col 30
            if _v is not None: write(_filter(_v, rawExpr='$row.mac')) # from line 196, col 30.
            write('''&days=''')
            _v = VFFSL(SL,"form.days",True) # '$form.days' on line 196, col 44
            if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 196, col 44.
            write('''&dns=''')
            _v = VFFSL(SL,"form.dns",True) # '$form.dns' on line 196, col 59
            if _v is not None: write(_filter(_v, rawExpr='$form.dns')) # from line 196, col 59.
            write('''" title="Search again for this MAC address">''')
            _v = VFFSL(SL,"macformatted",True) # '$macformatted' on line 196, col 112
            if _v is not None: write(_filter(_v, rawExpr='$macformatted')) # from line 196, col 112.
            write('''</a></td>
\t<td><a href="/browse/''')
            _v = VFFSL(SL,"row.switch",True) # '$row.switch' on line 197, col 23
            if _v is not None: write(_filter(_v, rawExpr='$row.switch')) # from line 197, col 23.
            write('''" title="Browse this switch (IP device)">''')
            _v = VFFSL(SL,"row.switch",True) # '$row.switch' on line 197, col 75
            if _v is not None: write(_filter(_v, rawExpr='$row.switch')) # from line 197, col 75.
            write('''</a></td>
\t<td style="text-align: center;">''')
            _v = VFFSL(SL,"row.module",True) # '$row.module' on line 198, col 34
            if _v is not None: write(_filter(_v, rawExpr='$row.module')) # from line 198, col 34.
            write('''</td>
        <td style="text-align: center;"><a href="swp?switch=''')
            _v = VFFSL(SL,"row.switch",True) # '$row.switch' on line 199, col 61
            if _v is not None: write(_filter(_v, rawExpr='$row.switch')) # from line 199, col 61.
            write('''&module=''')
            _v = VFFSL(SL,"row.module",True) # '$row.module' on line 199, col 80
            if _v is not None: write(_filter(_v, rawExpr='$row.module')) # from line 199, col 80.
            write('''&port=''')
            _v = VFFSL(SL,"row.port",True) # '$row.port' on line 199, col 97
            if _v is not None: write(_filter(_v, rawExpr='$row.port')) # from line 199, col 97.
            write('''&days=''')
            _v = VFFSL(SL,"form.days",True) # '$form.days' on line 199, col 112
            if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 199, col 112.
            write('''&dns=''')
            _v = VFFSL(SL,"form.dns",True) # '$form.dns' on line 199, col 127
            if _v is not None: write(_filter(_v, rawExpr='$form.dns')) # from line 199, col 127.
            write('''" title="Search for other machines on this port">''')
            _v = VFFSL(SL,"row.port",True) # '$row.port' on line 199, col 185
            if _v is not None: write(_filter(_v, rawExpr='$row.port')) # from line 199, col 185.
            write('''</a></td>
\t<td>''')
            _v = VFFSL(SL,"row.start_time",True) # '$row.start_time' on line 200, col 6
            if _v is not None: write(_filter(_v, rawExpr='$row.start_time')) # from line 200, col 6.
            write('''</td>
\t<td>''')
            _v = VFFSL(SL,"row.end_time",True) # '$row.end_time' on line 201, col 6
            if _v is not None: write(_filter(_v, rawExpr='$row.end_time')) # from line 201, col 6.
            write('''</td>
    </tr>
''')
        write('''</table>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def content(self, **KWS):



        ## CHEETAH: generated from #block content at line 33, 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('''
<div id="machinetracker" style="font-size: 13px;">

<h1>Machine Tracker</h1>

<p><a href="ip">IP Search</a>
| <a href="mac">MAC Search</a>
| <a href="swp">Switch Search</a></p>

''')
        if len(VFFSL(SL,"errors",True)) > 0: # generated from line 43, col 1
            write('''<div class="errors">
  <ul>
''')
            for error in VFFSL(SL,"errors",True): # generated from line 46, col 1
                write('''    <li>''')
                _v = VFFSL(SL,"escape",False)(VFFSL(SL,"error",True)) # '$escape($error)' on line 47, col 9
                if _v is not None: write(_filter(_v, rawExpr='$escape($error)')) # from line 47, col 9.
                write('''</li>
''')
            write('''  </ul>
</div>
''')
        write('''
<div id="forms">
''')
        if VFFSL(SL,"form.dns",True)=="on": # generated from line 54, col 1
            checked = "checked"
        else: # generated from line 56, col 1
            checked = ""
        if VFFSL(SL,"form.aip",True)=="on": # generated from line 59, col 1
            activechecked = "checked"
        else: # generated from line 61, col 1
            activechecked = ""
        if VFFSL(SL,"form.naip",True)=="on": # generated from line 64, col 1
            inactivechecked = "checked"
        else: # generated from line 66, col 1
            inactivechecked = ""
        write('''
''')
        if VFFSL(SL,"form.search",True)=="mac": # generated from line 70, col 1
            write('''<form id="macform" action="" method="get">
\t<label>MAC </label><input type="text" name="mac" value="''')
            _v = VFFSL(SL,"escape",False)(VFFSL(SL,"form.mac",True)) # '$escape($form.mac)' on line 72, col 58
            if _v is not None: write(_filter(_v, rawExpr='$escape($form.mac)')) # from line 72, col 58.
            write('''">
''')
            # 	<input type=checkbox name=aip $activechecked><label>active</label>
            # 	<input type=checkbox name=naip $inactivechecked><label>inactive</label>
            write('''\t<input type="checkbox" name="dns" ''')
            _v = VFFSL(SL,"checked",True) # '$checked' on line 75, col 36
            if _v is not None: write(_filter(_v, rawExpr='$checked')) # from line 75, col 36.
            write('''><label>dns</label>
''')
            if VFFSL(SL,"form.days",True): # generated from line 76, col 1
                write('''\t<input type="text" size="3" style="text-align: center;" name="days" value="''')
                _v = VFFSL(SL,"form.days",True) # '$form.days' on line 77, col 77
                if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 77, col 77.
                write('''"><label> days</label>
''')
            else: # generated from line 78, col 1
                write('''\t<input type="text" size="3" style="text-align: center;" name="days" value="7"><label> days</label>
''')
            write('''\t<input type="submit" name="send" value="Search">
</form>

''')
        elif VFFSL(SL,"form.search",True)=="swp": # generated from line 84, col 1
            write('''<form id="swpform" action="" method="get">
\t<label>Switch </label><input type="text" name="switch" value="''')
            _v = VFFSL(SL,"escape",False)(VFFSL(SL,"form.switch",True)) # '$escape($form.switch)' on line 86, col 64
            if _v is not None: write(_filter(_v, rawExpr='$escape($form.switch)')) # from line 86, col 64.
            write('''">
\t<label>Module </label><input type="text" name="module" size="3" value="''')
            _v = VFFSL(SL,"form.module",True) # '$form.module' on line 87, col 73
            if _v is not None: write(_filter(_v, rawExpr='$form.module')) # from line 87, col 73.
            write('''">
\t<label>Port </label><input type="text" name="port" size="3" value="''')
            _v = VFFSL(SL,"form.port",True) # '$form.port' on line 88, col 69
            if _v is not None: write(_filter(_v, rawExpr='$form.port')) # from line 88, col 69.
            write('''">
''')
            # 	<input type=checkbox name=aip $activechecked><label>active</label>
            # 	<input type=checkbox name=naip $inactivechecked><label>inactive</label>
            write('''\t<input type="checkbox" name="dns" ''')
            _v = VFFSL(SL,"checked",True) # '$checked' on line 91, col 36
            if _v is not None: write(_filter(_v, rawExpr='$checked')) # from line 91, col 36.
            write('''><label>dns</label>
''')
            if VFFSL(SL,"form.days",True): # generated from line 92, col 1
                write('''\t<input type="text" size="3" style="text-align: center;" name="days" value="''')
                _v = VFFSL(SL,"form.days",True) # '$form.days' on line 93, col 77
                if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 93, col 77.
                write('''"><label> days</label>
''')
            else: # generated from line 94, col 1
                write('''\t<input type="text" size="3" style="text-align: center;" name="days" value="7"><label> days</label>
''')
            write('''\t<input type="submit" name="send" value="Search">
</form>

''')
        else: # generated from line 100, col 1
            write('''
<form id="ipform" action="" method="get">
\t<label>IP from </label><input type="text" name="from_ip" value="''')
            _v = VFFSL(SL,"escape",False)(VFFSL(SL,"form.ip_from",True)) # '$escape($form.ip_from)' on line 103, col 66
            if _v is not None: write(_filter(_v, rawExpr='$escape($form.ip_from)')) # from line 103, col 66.
            write('''">
\t<label>to </label><input type="text" name="to_ip" value="''')
            _v = VFFSL(SL,"escape",False)(VFFSL(SL,"form.ip_to",True)) # '$escape($form.ip_to)' on line 104, col 59
            if _v is not None: write(_filter(_v, rawExpr='$escape($form.ip_to)')) # from line 104, col 59.
            write('''">
\t<input type="checkbox" name="aip" ''')
            _v = VFFSL(SL,"activechecked",True) # '$activechecked' on line 105, col 36
            if _v is not None: write(_filter(_v, rawExpr='$activechecked')) # from line 105, col 36.
            write('''><label>active</label>
\t<input type="checkbox" name="naip" ''')
            _v = VFFSL(SL,"inactivechecked",True) # '$inactivechecked' on line 106, col 37
            if _v is not None: write(_filter(_v, rawExpr='$inactivechecked')) # from line 106, col 37.
            write('''><label>inactive</label>
\t<input type="checkbox" name="dns" ''')
            _v = VFFSL(SL,"checked",True) # '$checked' on line 107, col 36
            if _v is not None: write(_filter(_v, rawExpr='$checked')) # from line 107, col 36.
            write('''><label>dns</label>
''')
            if VFFSL(SL,"form.days",True): # generated from line 108, col 1
                write('''\t<input type="text" size="3" style="text-align: center;" name="days" value="''')
                _v = VFFSL(SL,"form.days",True) # '$form.days' on line 109, col 77
                if _v is not None: write(_filter(_v, rawExpr='$form.days')) # from line 109, col 77.
                write('''"><label> days</label>
''')
            else: # generated from line 110, col 1
                write('''\t<input type="text" size="3" style="text-align: center;" name="days" value="7"><label> days</label>
''')
            write('''\t<input type="submit" name="send" value="Search">
</form>

''')
        write('''</div> <!-- forms -->

<br />





<div id="results">
''')
        if VFFSL(SL,"tableCam",True): # generated from line 208, col 1
            write('''    ''')
            _v = VFFSL(SL,"camTable",False)(VFFSL(SL,"tableCam.table",True)) # '$camTable($tableCam.table)' on line 209, col 5
            if _v is not None: write(_filter(_v, rawExpr='$camTable($tableCam.table)')) # from line 209, col 5.
            write('''
''')
        if VFFSL(SL,"tableArp",True): # generated from line 211, col 1
            write('''    ''')
            _v = VFFSL(SL,"arpTable",False)(VFFSL(SL,"tableArp.table",True)) # '$arpTable($tableArp.table)' on line 212, col 5
            if _v is not None: write(_filter(_v, rawExpr='$arpTable($tableArp.table)')) # from line 212, col 5.
            write('''
''')
        if VFFSL(SL,"tableSwp",True): # generated from line 214, col 1
            write('''    ''')
            _v = VFFSL(SL,"camTable",False)(VFFSL(SL,"tableSwp.table",True)) # '$camTable($tableSwp.table)' on line 215, col 5
            if _v is not None: write(_filter(_v, rawExpr='$camTable($tableSwp.table)')) # from line 215, col 5.
            write('''
''')
        write('''
''')
        if not VFFSL(SL,"tableCam",True) and not VFFSL(SL,"tableArp",True) and not VFFSL(SL,"tableSwp",True): # generated from line 218, col 1
            noresults = 0
            if VFFSL(SL,"form.search",True) == "mac": # generated from line 220, col 3
                if VFFSL(SL,"form.mac",True): # generated from line 221, col 5
                    noresults = 1
            elif VFFSL(SL,"form.search",True) == "swp": # generated from line 224, col 3
                if VFFSL(SL,"form.switch",True): # generated from line 225, col 5
                    noresults = 1
            else: # generated from line 228, col 3
                if VFFSL(SL,"form.ip_from",True): # generated from line 229, col 5
                    noresults = 1
            write('''
''')
            if VFFSL(SL,"noresults",True): # generated from line 234, col 3
                write('''<p>Your search did not return any results</p>
''')
            else: # generated from line 236, col 3
                write('''<div class="infobox">

<h2>Machine Tracker Search Hints</h2>
<ul>
  <li>MAC search allows wildcard searching, e.g. you can search for
      &quot;<tt>00aabbcc*</tt>&quot;</li>
  <li>Switch search will search for switches having a sysname that
      starts with whatever you enter as switch name.  E.g. searching
      for &quot;<tt>blapp-sw</tt>&quot; will retrieve both
      &quot;<tt>blapp-sw.ntnu.no</tt>&quot; and
      &quot;<tt>blapp-sw2.ntnu.no</tt>&quot;</li>
  <li>Leaving the <i>module</i> or <i>port</i> fields empty in the
      switch search will find any module or port that have matching
      records for your selected switch.</li>
</ul>

<h2>Accuracy of the Machine Tracker Results</h2>
<ul>
    <li>IP search results are based on ARP data from routers. Typically ARP
    data entries are kept by the routers 4 hours after the last packet seen.
    Also keep in mind, the ARP collector only runs twice an hour (0,30).
    Subtracting 4-4.5 hours from the end time gives you a fairly good
    idea.</li>
    <li>MAC search results are based on switch bridge tables. Default timeout
    for bridge table entries may vary, in many cases it is 5 minutes. The
    bridge table collector runs every 15 minutes (11,26,41,59) which also
    introduces some inaccuracy. In other words, the results may be 5-20 minutes
    off.</li>
</ul>

</div>

''')
        write('''</div> <!-- results -->


</div> <!-- machinetracker -->

''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def additionalCSS(self, **KWS):



        ## CHEETAH: generated from #block additionalCSS at line 278, 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
        
        _v = VFFSL(SL,"default_table_CSS",True) # '$default_table_CSS' on line 279, col 1
        if _v is not None: write(_filter(_v, rawExpr='$default_table_CSS')) # from line 279, col 1.
        write('''
<link rel="stylesheet" type="text/css" href="/style/machinetracker.css" />
''')
        
        ########################################
        ## 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
        
        #  $Id: MachineTrackerTemplate.tmpl 3825 2007-01-26 14:52:44Z jodal $
        # 
        #  Copyright 2003, 2004 Norwegian University of Science and Technology
        #  Copyright 2006 UNINETT AS
        # 
        #  This file is part of Network Administration Visualized (NAV)
        # 
        #  NAV is free software; you can redistribute it and/or modify
        #  it under the terms of the GNU General Public License as published by
        #  the Free Software Foundation; either version 2 of the License, or
        #  (at your option) any later version.
        # 
        #  NAV is distributed in the hope that it will be useful,
        #  but WITHOUT ANY WARRANTY; without even the implied warranty of
        #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        #  GNU General Public License for more details.
        # 
        #  You should have received a copy of the GNU General Public License
        #  along with NAV; if not, write to the Free Software
        #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        # 
        # 
        #  Author: Magnar Sveen <magnars@idi.ntnu.no>
        #          Sigurd Gartmann <sigurd-nav@brogar.org>
        # 
        write('''


''')
        self.content(trans=trans)
        write('''
''')
        self.additionalCSS(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__

    path =  [("Home", "/"), ("Machine Tracker", "/machinetracker/")]

    _mainCheetahMethod_for_MachineTrackerTemplate= 'writeBody'

## END CLASS DEFINITION

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


# 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=MachineTrackerTemplate()).run()


