From fcf6a8630b7ae818e7719d6e811d01d9359388c3 Mon Sep 17 00:00:00 2001 From: ficus Date: Tue, 2 Oct 2012 16:44:03 +0200 Subject: remove unused told TUI --- packages/torouter-web/src/tui/utils/parsing.py | 145 ------------------------- 1 file changed, 145 deletions(-) delete mode 100644 packages/torouter-web/src/tui/utils/parsing.py (limited to 'packages/torouter-web/src/tui/utils/parsing.py') diff --git a/packages/torouter-web/src/tui/utils/parsing.py b/packages/torouter-web/src/tui/utils/parsing.py deleted file mode 100644 index 310ea5c..0000000 --- a/packages/torouter-web/src/tui/utils/parsing.py +++ /dev/null @@ -1,145 +0,0 @@ -# These functions are for parsing /etc/network/interface -# files, they will be used inside torouter to visualize -# and edit configuration -import os, re -from tui import config - -class interfaces: - def __init__(self,filename): - self.filename = filename - try: - self.fp = open(filename, "r") - except: - # this will happen on our first run or at reboot - self.fp = open("/etc/tor/torrc", "r") - self.wifi = {} - self.eth1 = {} - self.eth0 = {} - - def exclude_output(self, iexclude): - iface = None - output = "" - self.fp = open(self.filename, "r") - for line in self.fp.readlines(): - if line.lstrip().startswith("iface"): - iface = line.split(" ")[1] - if iface == iexclude: - continue - else: - output += line - return output - - def parse_line(self, line, iface): - name = line.split(" ")[0] - values = " ".join(line.split(" ")[1:]).rstrip() - if iface == config.network_interfaces[0]: - if self.wifi.has_key(name): - if type(self.wifi[name]) is list: - self.wifi[name].append(values) - else: - self.wifi[name] = [self.wifi[name],values] - else: - self.wifi.update({name : values}) - elif iface == config.network_interfaces[2]: - if self.eth1.has_key(name): - if type(self.eth1[name]) is list: - self.eth1[name].append(values) - else: - self.eth1[name] = [self.eth1[name],values] - else: - self.eth1.update({name : values}) - elif iface == config.network_interfaces[1]: - if self.eth0.has_key(name): - if type(self.eth0[name]) is list: - self.eth0[name].append(values) - else: - self.eth0[name] = [self.eth0[name],values] - else: - self.eth0.update({name : values}) - - def parse(self): - iface = None - for line in self.fp.readlines(): - line = line.lstrip() - if line.startswith("#") or line == "": - continue - if line.startswith("iface"): - iface = line.split(" ")[1] - if iface: - self.parse_line(line, iface) - - def html_output(self, data): - output = "

Interface %s

\n" % data['iface'].split(" ")[0] - output += "\n" % data['iface'].split(" ")[0] - - for item in data.items(): - if item[0] != "iface": - if type(item[1]) is list: - for i in item[1]: - output += "\n" % (item[0], i) - else: - output += "\n" % (item[0],item[1]) - output += "
%s%s
%s%s
" - print output - return output - - def output(self, data): - output = "iface %s\n" % data['iface'] - for item in data.items(): - if item[0] != "iface": - if type(item[1]) is list: - for i in item[1]: - output += item[0] + " " + i + "\n" - else: - output += item[0] + " " + item[1] + "\n" - return output - - def set_ssid(self, essid): - i = 0 - for entry in self.wifi['post-up']: - if re.search("sys_cfg_ssid", entry): - print essid - self.wifi['post-up'][i] = '/usr/bin/uaputl sys_cfg_ssid "' + essid + '"' - i += 1 - - # XXX currently works for one pre-up entry, must make it work also for arrays - def set_mac(self, mac): - self.wifi['pre-up'] = 'ifconfig ' + config.network_interfaces[0] + ' hw ether ' + mac - - -class torrc: - def __init__(self,filename): - self.fp = open(filename, "r") - self.parsed = [] - - def parse(self): - for line in self.fp.readlines(): - line = line.lstrip() - if line.startswith("#") or line == "": - continue - else: - self.parsed.append(line) - - def output(self): - output = "" - for line in self.fp.readlines(): - print line - output += line - return output - - def html_output(self): - output = "" - print output - return output - -#interfaces_file = os.getcwd() + "/../../../torouter-prep/configs/interfaces" -#itfc = interfaces(interfaces_file) -#itfc.parse() -#itfc.html_output(itfc.wifi) -#itfc.html_output(itfc.eth1) -#itfc.html_output(itfc.eth0) - -- cgit v1.2.3