#!/usr/bin/python # import urllib2 import string import sys import time import datetime import socket def read_accepted(): global dhcp_accepted dhcp_accepted = [] try: infile = open('/tmp/dhcp.leases', 'r') except(IOError), e: print "couldn't open accepted" else: filelist = infile.readlines() infile.close() for item in filelist: item=item.strip() macaddress=item.split(" ")[1] if macaddress not in dhcp_accepted: dhcp_accepted.append(macaddress) #print macaddress def read_offered(): global dhcp_offered dhcp_offered = [] try: today = datetime.date.today() host = socket.gethostname() filename='/var/log/' filename+=str(today) filename+='/' filename+=host filename+='/dnsmasq' infile = open(filename, 'r') except(IOError), e: print "couldn't open offered" else: filelist = infile.readlines() infile.close() for item in filelist: item=item.strip() if item.find("DHCPOFFER") != -1 : macaddress=item.rpartition(" ")[2] if macaddress not in dhcp_offered: dhcp_offered.append(macaddress) #print macaddress def read_current(): global dhcp_current dhcp_current = [] try: infile = open('/etc/dnsmasq.mvpmc.conf', 'r') except(IOError), e: print "couldn't open current" else: filelist = infile.readlines() infile.close() for item in filelist: item=item.strip() if item.find("dhcp-host") != -1 : macaddress=item.partition(",")[2] if macaddress not in dhcp_current : dhcp_current.append(macaddress) # print macaddress def make_html(): global dhcp_accepted global dhcp_offered buttonform_top='''