#!/usr/bin/python import cgi import os import re from config import readConfigFile from time import time from xml.dom.minidom import parse def getIds(): group_id='' host_id='' f=open('/etc/sysconfig/vpn', 'r') lines=f.readlines() f.close() for line in lines: if line[-1]=='\n': line=line[:-1] if 'GROUP_ID' in line: group_id=re.sub('^GROUP_ID="(.*)"', '\\1', line) if 'HOST_ID' in line: host_id=re.sub('^HOST_ID="(.*)"', '\\1', line) return (group_id, host_id) def getInterfaces(): try: f=open('/proc/net/dev', 'r') try: int_list=f.readlines() finally: f.close() #keep only interface's name int_list=[ int.split(':')[0] for int in int_list[2:] ] except IOError: int_list="" return int_list def removeLtGt(lines): newlines=[] for line in lines: line=re.sub('<','<',line) line=re.sub('>','>',line) newlines += [line] return newlines def executeCommand(command): try: f=os.popen(command, 'r') try: command_result=f.readlines() finally: f.close() except IOError: command_result="" return command_result #header print "Content-Type: text/html" print print '''