+++ /dev/null
-###############################################################################
-# IPFire.org - An Open Source Firewall Solution #
-# Copyright (C) - IPFire Development Team <info@ipfire.org> #
-###############################################################################
-
-name = pyfire
-version = 0.99.1
-release = 1
-
-groups = System/Libraries
-url = http://www.ipfire.org
-license = GPLv3+
-summary = A python library for easy functions.
-
-description
- Pyfire is a library which offers a lot of easy to use functions.
-end
-
-build
- requires
- python
- end
-
- DIR_APP = %{DIR_SOURCE}/src
-
- prepare = # Nothing to do
-
- build = # Nothing to do
-
- install
- make install DESTDIR=%{BUILDROOT}
- make clean
- end
-end
-
-packages
- package %{name}
-
- package %{name}-debuginfo
- template DEBUGINFO
- end
-end
+++ /dev/null
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
-# #
-# This program 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 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-NAME = pyfire
-
-PYTHONLIBDIR = $(DESTDIR)/usr/lib/python2.6/site-packages/$(NAME)
-
-all:
-
-install: all
- -mkdir -p $(PYTHONLIBDIR)
- cp -avf *.py $(PYTHONLIBDIR)
-
-clean:
- rm -f *.o *.so *.pyc *.pyo
+++ /dev/null
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
-# #
-# This program 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 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-__all__ = [ "config", "executil", "hal", "net", "translate", "web", ]
-
-import os
-
-import hal
-
-class System:
- def __init__(self):
- self.dbus = hal.get_device("/org/freedesktop/Hal/devices/computer")
-
- def getKernelVersion(self):
- ret = None
- try:
- ret = self.dbus["system.kernel.version"]
- except KeyError:
- pass
- return ret
-
- def getFormfactor(self):
- return self.dbus["system.formfactor"]
-
- def getVendor(self):
- ret = None
- try:
- ret = self.dbus["system.vendor"]
- except KeyError:
- pass
- return ret
-
- def getProduct(self):
- ret = None
- try:
- ret = self.dbus["system.product"]
- except KeyError:
- pass
- return ret
-
-
-if __name__ == "__main__":
- system = System()
- print "Kernel Version : %s" % system.getKernelVersion()
- print "System Formfactor : %s" % system.getFormfactor()
- print "System Vendor : %s" % system.getVendor()
- print "System Product : %s" % system.getProduct()
+++ /dev/null
-#
-# simpleconifg.py - representation of a simple configuration file (sh-like)
-#
-# Matt Wilson <msw@redhat.com>
-# Jeremy Katz <katzj@redhat.com>
-#
-# Copyright 1999-2002 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-import string
-import os
-
-# use our own ASCII only uppercase function to avoid locale issues
-# not going to be fast but not important
-def uppercase_ASCII_string(str):
- newstr = ""
- for i in range(0,len(str)):
- if str[i] in string.lowercase:
- newstr += chr(ord(str[i])-32)
- else:
- newstr += str[i]
-
- return newstr
-
-class ConfigFile:
- def __str__ (self):
- s = ""
- keys = self.info.keys ()
- keys.sort ()
- for key in keys:
- # FIXME - use proper escaping
- if type(self.info[key]) == type(""):
- s = s + key + "=\"" + self.info[key] + "\"\n"
- return s
-
- def __init__ (self, filename):
- self.info = {}
- self.filename = filename
- self.read()
-
- def write(self, filename=None):
- if not filename:
- filename = self.filename
- f = open(filename, "w")
- f.write(self.__str__())
- f.close()
-
- def read(self, filename=None):
- if not filename:
- filename = self.filename
- if not os.access(filename, os.R_OK):
- return
-
- f = open(filename, "r")
- lines = f.readlines()
- f.close()
-
- for line in lines:
- fields = line[:-1].split('=', 2)
- if len(fields) < 2:
- # how am I supposed to know what to do here?
- continue
- key = uppercase_ASCII_string(fields[0])
- value = fields[1]
- # XXX hack
- value = value.replace('"', '')
- value = value.replace("'", '')
- self.info[key] = value
-
- def set(self, *args):
- for (key, data) in args:
- self.info[uppercase_ASCII_string(key)] = data
-
- def unset(self, *keys):
- for key in keys:
- key = uppercase_ASCII_string(key)
- if self.info.has_key (key):
- del self.info[key]
-
- def get(self, key):
- key = uppercase_ASCII_string(key)
- if self.info.has_key (key):
- return self.info[key]
- else:
- return ""
+++ /dev/null
-#
-# executil.py - generic utility functions for executing programs
-#
-# Erik Troan <ewt@redhat.com>
-#
-# Copyright 1999-2002 Red Hat, Inc.
-#
-# This software may be freely redistributed under the terms of the GNU
-# library public license.
-#
-# You should have received a copy of the GNU Library Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-import os
-import sys
-import types
-import select
-import signal
-
-def getfd(filespec, readOnly = 0):
- if type(filespec) == types.IntType:
- return filespec
- if filespec == None:
- filespec = "/dev/null"
-
- flags = os.O_RDWR | os.O_CREAT
- if (readOnly):
- flags = os.O_RDONLY
- return os.open(filespec, flags)
-
-def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
- searchPath = 0, root = '/', newPgrp = 0, ignoreTermSigs = 0):
- stdin = getfd(stdin)
- if stdout == stderr:
- stdout = getfd(stdout)
- stderr = stdout
- else:
- stdout = getfd(stdout)
- stderr = getfd(stderr)
-
- childpid = os.fork()
- if (not childpid):
- if (root and root != '/'):
- os.chroot(root)
- os.chdir("/")
-
- if ignoreTermSigs:
- signal.signal(signal.SIGTSTP, signal.SIG_IGN)
- signal.signal(signal.SIGINT, signal.SIG_IGN)
-
- if type(stdin) == type("a"):
- stdin = os.open(stdin, os.O_RDONLY)
- if type(stdout) == type("a"):
- stdout = os.open(stdout, os.O_RDWR)
- if type(stderr) == type("a"):
- stderr = os.open(stderr, os.O_RDWR)
-
- if stdin != 0:
- os.dup2(stdin, 0)
- os.close(stdin)
- if stdout != 1:
- os.dup2(stdout, 1)
- if stdout != stderr:
- os.close(stdout)
- if stderr != 2:
- os.dup2(stderr, 2)
- os.close(stderr)
-
- if (searchPath):
- os.execvp(command, argv)
- else:
- os.execv(command, argv)
-
- sys.exit(1)
-
- if newPgrp:
- os.setpgid(childpid, childpid)
- oldPgrp = os.tcgetpgrp(0)
- os.tcsetpgrp(0, childpid)
-
- status = -1
- try:
- (pid, status) = os.waitpid(childpid, 0)
- except OSError, (errno, msg):
- print __name__, "waitpid:", msg
-
- if newPgrp:
- os.tcsetpgrp(0, oldPgrp)
-
- return status
-
-## Run an external program and capture standard out.
-# @param command The command to run.
-# @param argv A list of arguments.
-# @param stdin The file descriptor to read stdin from.
-# @param stderr The file descriptor to redirect stderr to.
-# @param root The directory to chroot to before running command.
-# @return The output of command from stdout.
-def execWithCapture(command, argv, stdin = 0, stderr = 2, root='/'):
- def chroot():
- os.chroot(root)
-
- argv = list(argv)
- if type(stdin) == type("string"):
- if os.access(stdin, os.R_OK):
- stdin = open(stdin)
- else:
- stdin = 0
- if type(stderr) == type("string"):
- stderr = open(stderr, "w")
-
- try:
- pipe = subprocess.Popen([command] + argv, stdin=stdin,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- preexec_fn=chroot, cwd=root)
- except OSError, (errno, msg):
- log.error ("Error running " + command + ": " + msg)
- raise RuntimeError, "Error running " + command + ": " + msg
-
- rc = pipe.stdout.read()
- pipe.wait()
- return rc
-
-def execWithCaptureStatus(command, argv, searchPath = 0, root = '/', stdin = 0,
- catchfd = 1, closefd = -1):
-
- if not os.access (root + command, os.X_OK):
- raise RuntimeError, command + " can not be run"
-
- (read, write) = os.pipe()
-
- childpid = os.fork()
- if (not childpid):
- if (root and root != '/'): os.chroot (root)
- if isinstance(catchfd, tuple):
- for fd in catchfd:
- os.dup2(write, fd)
- else:
- os.dup2(write, catchfd)
- os.close(write)
- os.close(read)
-
- if closefd != -1:
- os.close(closefd)
-
- if stdin:
- os.dup2(stdin, 0)
- os.close(stdin)
-
- if (searchPath):
- os.execvp(command, argv)
- else:
- os.execv(command, argv)
-
- sys.exit(1)
-
- os.close(write)
-
- rc = ""
- s = "1"
- while (s):
- select.select([read], [], [])
- s = os.read(read, 1000)
- rc = rc + s
-
- os.close(read)
-
- status = None
-
- try:
- (pid, status) = os.waitpid(childpid, 0)
- except OSError, (errno, msg):
- print __name__, "waitpid:", msg
-
- if os.WIFEXITED(status) and (os.WEXITSTATUS(status) == 0):
- status = os.WEXITSTATUS(status)
- else:
- status = -1
-
- return (rc, status)
-
-def execWithCaptureErrorStatus(command, argv, searchPath = 0, root = '/',
- stdin = 0, catchfd = 1, catcherrfd = 2, closefd = -1):
-
- if not os.access (root + command, os.X_OK):
- raise RuntimeError, command + " can not be run"
-
- (read, write) = os.pipe()
- (read_err,write_err) = os.pipe()
-
- childpid = os.fork()
- if (not childpid):
- if (root and root != '/'): os.chroot (root)
- if isinstance(catchfd, tuple):
- for fd in catchfd:
- os.dup2(write, fd)
- else:
- os.dup2(write, catchfd)
- os.close(write)
- os.close(read)
-
- if isinstance(catcherrfd, tuple):
- for fd in catcherrfd:
- os.dup2(write_err, fd)
- else:
- os.dup2(write_err, catcherrfd)
- os.close(write_err)
- os.close(read_err)
-
- if closefd != -1:
- os.close(closefd)
-
- if stdin:
- os.dup2(stdin, 0)
- os.close(stdin)
-
- if (searchPath):
- os.execvp(command, argv)
- else:
- os.execv(command, argv)
-
- sys.exit(1)
-
- os.close(write)
- os.close(write_err)
-
- rc = ""
- rc_err = ""
- s = "1"
- t = "1"
- while (s or t):
- select.select([read], [], [])
- s = os.read(read, 1000)
- t = os.read(read_err, 1000)
- rc = rc + s
- rc_err = rc_err + t
-
- os.close(read)
- os.close(read_err)
-
- status = None
-
- try:
- (pid, status) = os.waitpid(childpid, 0)
- except OSError, (errno, msg):
- print __name__, "waitpid:", msg
-
- if os.WIFEXITED(status) and (os.WEXITSTATUS(status) == 0):
- status = os.WEXITSTATUS(status)
- else:
- status = -1
-
- return (rc, rc_err, status)
+++ /dev/null
-#
-# minihal.py: Simple wrapper around HAL
-#
-# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
-#
-# This program 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.
-#
-# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Author(s): Bill Nottingham <notting@redhat.com>
-#
-
-"""Simple wrapper around HAL"""
-
-import dbus
-
-def get_device(udi):
- """Retrieve all properties of a particular device (by UDI)"""
- try:
- bus = dbus.SystemBus()
- haldev = dbus.Interface(bus.get_object("org.freedesktop.Hal", udi), "org.freedesktop.Hal.Device")
- props = haldev.GetAllProperties()
- except dbus.exceptions.DBusException:
- return None
-
- if props.has_key('block.device'):
- props['device'] = props['block.device'].encode("utf-8")
- elif props.has_key('linux.device_file'):
- props['device'] = props['linux.device_file'].encode("utf-8")
- elif props.has_key('net.interface'):
- props['device'] = props['net.interface'].encode("utf-8")
- else:
- props['device'] = None
-
- props['description'] = ''
- if props.has_key('info.product'):
- if props.has_key('info.vendor'):
- props['description'] = '%s %s' % (props['info.vendor'],props['info.product'])
- else:
- props['description'] = props['info.product']
- else:
- props['description'] = props['info.udi']
- if props.has_key('net.originating_device'):
- pdev = get_device(props['net.originating_device'])
- props['description'] = pdev['description']
-
- return props
-
-def get_devices_by_type(type):
- """Retrieve all devices of a particular type"""
- ret = []
- try:
- bus = dbus.SystemBus()
- hal = dbus.Interface(bus.get_object("org.freedesktop.Hal","/org/freedesktop/Hal/Manager"),"org.freedesktop.Hal.Manager")
- except:
- return ret
- for udi in hal.FindDeviceByCapability(type):
- dev = get_device(udi)
- if dev:
- ret.append(dev)
- return ret
+++ /dev/null
-#!/usr/bin/python
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
-# #
-# This program 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 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-import os
-import os.path
-import socket
-import string
-
-import hal
-from config import ConfigFile
-
-NETWORK_DEVICES="/etc/sysconfig/network-devices/"
-NETWORK_SETTINGS="/etc/sysconfig/network"
-NETWORK_SCRIPTS="/etc/init.d/networking/"
-
-class Network:
- def __init__(self):
- self.bridges = {}
- self.nics = {}
-
- self.settings = NetworkSettings(NETWORK_SETTINGS)
-
- def getNics(self):
- for device in hal.get_devices_by_type("net"):
- if device.has_key('net.arp_proto_hw_id'):
- if device['net.arp_proto_hw_id'] == 1 and \
- not device['info.category'] == 'net.bridge':
- nic = device['device']
- self.nics[nic] = NetworkDevice(nic, device)
- return self.nics
-
- def getNic(self, nic):
- return self.nics[nic]
-
- def getBridges(self, colour=None):
- for file in os.listdir(NETWORK_DEVICES):
- bridge = os.path.basename(file)
- if colour and not bridge.startswith(colour):
- continue
- self.bridges[bridge] = BrideDevice(bridge)
- return self.bridges
-
- def getBridge(self, bridge):
- return self.bridges[bridge]
-
- def addBridge(self, dev):
- self.bridges[dev] = BridgeDevice(dev)
-
- def delBridge(self, dev):
- self.bridges[dev].remove()
- del self.bridges[dev]
-
- def write(self):
- for bridge in self.bridges.items():
- self.bridges[bridge].write()
- self.settings.write()
-
-
-class NetworkSettings(ConfigFile):
- def __init__(self, filename):
- ConfigFile.__init__(self, filename)
-
- def getHostname(self):
- return self.get("HOSTNAME")
-
- def setHostname(self, hostname):
- self.set(("HOSTNAME", hostname))
-
-
-class BridgeDevice:
- def __init__(self, dev):
- self.filename = "%s/%s/" % (NETWORK_DEVICES, dev,)
- self.device = dev
- self.services = []
-
- for file in os.listdir(self.filename):
- service = Service(file, bridge=self.device)
- self.addService(service)
-
- def addService(self, service):
- self.services.append(service)
-
- def getPolicy(self, service):
- ret = []
- for service in self.services:
- if service.service == service:
- ret.append(service)
- return ret
-
- def delService(self, service):
- pass # how to do this?
-
- def addNic(self, nic):
- # requires a NetworkDevice instance
- filename = os.path.join(self.filename, nic.getDevice())
- service = Service(filename, bridge=self.name, service="bridge-slave")
- service.set(("DESCRIPTION", nic.getDescription()),
- ("MAC", nic.getMac()))
- self.addService(service)
-
- def write(self):
- if not os.path.isdir(fn):
- os.makedirs(fn)
-
- # Save all service information
- for service in self.services:
- service.write()
-
-
-class NetworkDevice:
- def __init__(self, dev, dbus):
- self.device = dev
- self.dbus = dbus
-
- def __str__(self):
- return "%s (%s) - %s" % (self.device, self.getDescription(), self.getMac())
-
- def getDevice(self):
- return self.device
-
- def getMac(self):
- return self.dbus["net.address"]
-
- def getDescription(self):
- return self.dbus["description"]
-
-
-class ServiceError(Exception):
- pass
-
-
-class Service(ConfigFile):
- def __init__(self, filename, bridge=None, service=None):
- self.service = None
- if service:
- self.setService(service)
- ConfigFile.__init__(self, filename)
- self.bridge = bridge
- self.name = os.path.basename(self.filename)
-
- def setService(self, service):
- if not service in listAllServices():
- raise ServiceError, "The given service is not available: %s" % service
- self.service = service
-
-
-def listAllServices():
- ret = []
- for service in os.listdir(NETWORK_SCRIPTS + "services/"):
- ret.append(service)
- return ret
-
-if __name__ == "__main__":
- network = Network()
- print "All available nics on this system:"
- for nic, obj in network.getNics().items():
- print obj
+++ /dev/null
-#!/usr/bin/python
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
-# #
-# This program 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 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-import os
-import cgi
-
-import pyfire.net as net
-
-addPoPath("/srv/www/ipfire/cgi-bin/po/")
-textdomain("ipfire")
-
-### Variables
-allowed_endings = [ "cgi", "py",]
-
-class IPFireWeb:
- def __init__(self, title, icon):
- self.title = title
- self.icon = icon
- self.hostname = net.gethostname()
-
- ### This is a hash with all of the important vars:
- ## - "title" - The title of the current page
- ## - "icon" - The displayed icon
- ## - "hostname" - The local hostname
- self.info = { "title": self.title,
- "icon": self.icon,
- "hostname": self.hostname,
- }
-
- ### This is the menu tree
- ## Every index has got a hash with a few arguments:
- ## - "title" which is the title of the section
- ## - "subs" is a tuple with all the submenu items
- ## One submenu items looks like this:
- ## (_("Home"), "index.py")
- ## name of the item ^^^^ ^^^^^^^^ filename
- self.menu = {}
-
- for section in os.listdir("/etc/ipfire/menu"):
- f = open("/etc/ipfire/menu/" + section)
- self.menu[section] = { "title" : "", "subs" : [],}
- for line in f.readlines():
- (item, filename) = line.rstrip("\n").split(":",1)
- if item == "title":
- self.menu[section]["title"] = _(filename)
- else:
- self.menu[section]["subs"].append((_(item), filename))
- f.close()
-
- def __run__(self):
- ### This initializes the http(s) response
- self.showhttpheaders()
- self.getcgihash()
-
- ### Page
- self.openpage()
- self.content()
- self.closepage()
-
- def openpage(self):
- print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<!-- HTML HEADER -->
-<head>
- <title>%(hostname)s - IPFire v3 - %(title)s</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <link rel="shortcut icon" href="/favicon.ico" />
- <link rel="stylesheet" type="text/css" href="include/style.css" />
-</head>
-<!-- HTML HEADER END -->""" % self.info
- self.openheader()
- self.genbigmenu()
- self.closeheader()
- self.openbigbox()
-
- def closepage(self):
- self.closebigbox()
- self.footer()
-
- def openheader(self):
- print """
-<!-- HTML BODY -->
-<body>
- <!-- IPFIRE HEADER -->
- <div id="header">
- <div id="header_inner" class="fixed">
- <!-- IPFIRE LOGO -->
- <div id="logo">
- <img src="/images/icons/%(icon)s" width="48px" height="48px" alt="Symbol" class="symbol" />
- <h1><span>%(hostname)s</span></h1>
- <br />
- <h2>%(title)s</h2>
- </div>""" % self.info
- def closeheader(self):
- print """ </div>
- </div>
- <!-- IPFIRE HEADER END -->"""
-
- def openbigbox(self):
- print """
- <!-- IPFIRE BODY -->
- <div id="main">
- <div id="main_inner" class="fixed">
- <div id="primaryContent_2columns">
- <div id="columnA_2columns">
- <!-- IPFIRE CONTENT -->"""
-
- def openbox(self, title):
- print """
- <div class="post">
- <h3>%s</h3>""" % (title,)
-
- def closebox(self):
- print """
- </div>
- <br class="clear" />"""
-
- def closebigbox(self):
- print """
- <!-- IPFIRE CONTENT END -->
- </div>
- </div>"""
- self.genmenu()
-
- def genbigmenu(self):
- print """
- <!-- IPFIRE MENU -->
- <div id="menu">
- <ul>"""
- sections = self.menu.keys()
- sections.sort()
- for section in sections:
- filename = self.menu[section]["subs"][0][1]
- print "\t\t\t\t\t\t",
- print "<li><a href=\"/%s\">%s</a></li>" % \
- (filename, self.menu[section]["title"])
- print """
- </ul>
- </div>"""
-
- def genmenu(self):
- this_file = os.path.basename(os.environ["SCRIPT_NAME"])
- this_section = None
-
- for i in self.menu.keys():
- for j in self.menu[i]["subs"]:
- if this_file == os.path.basename(j[1]):
- this_section = i
- break
- if not this_section is None:
- break
-
- if this_section is None:
- return
-
- print """
- <div id="secondaryContent_2columns">
- <div id="columnC_2columns">
- <h4><span>Side</span>menu</h4>
- <ul class="links">"""
-
- for item in self.menu[this_section]["subs"]:
- print "\t\t\t\t\t\t\t",
- if item[1] == this_file:
- print "<li class=\"selected\">",
- else:
- print "<li>",
- print "<a href=\"/cgi-bin/%s\">%s</a></li>" \
- % (item[1], item[0],)
-
- print """
- </ul>
- </div>
- </div>
- <br class="clear" />"""
-
- def footer(self):
- print """
- <div id="footer" class="fixed">
- <span>Load average: %(load)s
- </div>""" % { "load" : os.getloadavg() }
- print """
- </div>
- </div>
-</body>
-</html>
-"""
-
- def showhttpheaders(self, type="text/html"):
- print "Pragma: no-cache"
- print "Cache-control: no-cache"
- print "Connection: close"
- print "Content-type:" + type
- print
- # An empty line ends the header
-
- def getcgihash(self):
- self.cgihash = cgi.FieldStorage()
-
- def content(self):
- self.openbox(_("Error"))
- print "This site has no content defined, yet. Please define site.content()."
- self.closebox()