diff options
-rw-r--r-- | packages/torouter-web/config.py | 2 | ||||
-rw-r--r-- | packages/torouter-web/tui/controllers/network.py | 10 | ||||
-rw-r--r-- | packages/torouter-web/tui/utils/parsing.py | 27 | ||||
-rw-r--r-- | packages/torouter-web/tui/views/status.html | 4 |
4 files changed, 35 insertions, 8 deletions
diff --git a/packages/torouter-web/config.py b/packages/torouter-web/config.py index 765c3df..8fd716d 100644 --- a/packages/torouter-web/config.py +++ b/packages/torouter-web/config.py @@ -11,3 +11,5 @@ globals = {} # Add your own (username, password) pair authinfo = ("test", "test") +interfaces_file = os.getcwd() + "/../torouter-prep/configs/interfaces" + diff --git a/packages/torouter-web/tui/controllers/network.py b/packages/torouter-web/tui/controllers/network.py index b5da4e3..d189d0c 100644 --- a/packages/torouter-web/tui/controllers/network.py +++ b/packages/torouter-web/tui/controllers/network.py @@ -1,7 +1,7 @@ import web import view, config from view import render -from tui.utils import session,configuration +from tui.utils import session,configuration,parsing """ This function is used to generate the network @@ -116,8 +116,14 @@ General status page, displays a bit more detail than main """ class status: def GET(self): - return render.base(render.status(),menu(4)) + itfc = parsing.interfaces(config.interfaces_file) + itfc.parse() + network = itfc.html_output(itfc.wifi) + itfc.html_output(itfc.eth0) + itfc.html_output(itfc.eth1) + return render.base(render.status(network),menu(4)) def POST(self): + itfc = parsing.interfaces(config.interfaces_file) + itfc.parse() + network = itfc.html_output(itfc.wifi) + itfc.html_output(itfc.eth0) + itfc.html_output(itfc.eth1) return render.base(render.status(),menu(4)) diff --git a/packages/torouter-web/tui/utils/parsing.py b/packages/torouter-web/tui/utils/parsing.py index c6ebe02..e9ccc83 100644 --- a/packages/torouter-web/tui/utils/parsing.py +++ b/packages/torouter-web/tui/utils/parsing.py @@ -1,6 +1,8 @@ # These functions are for parsing /etc/network/interface # files, they will be used inside torouter to visualize # and edit configuration +import os + class interfaces: def __init__(self,filename): self.fp = open(filename, "r") @@ -47,6 +49,20 @@ class interfaces: if iface: self.parse_line(line, iface) + def html_output(self, data): + output = "<h3>Interface %s</h3>\n" % data['iface'].split(" ")[0] + output += "<table class=\"interface\" id=\"%s\">\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 += "<tr><td>%s</td><td>%s</td></tr>\n" % (item[0], i) + else: + output += "<tr><td>%s</td><td>%s</td></tr>\n" % (item[0],item[1]) + output += "</table>" + print output + return output def output(self, data): print "iface %s" % data['iface'] @@ -58,9 +74,10 @@ class interfaces: else: print "%s %s" % (item[0],item[1]) -itfc = interfaces("/tmp/interfaces") -itfc.parse() -itfc.output(itfc.wifi) -itfc.output(itfc.eth1) -itfc.output(itfc.eth0) +#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) diff --git a/packages/torouter-web/tui/views/status.html b/packages/torouter-web/tui/views/status.html index 6a128dc..bfe2fcd 100644 --- a/packages/torouter-web/tui/views/status.html +++ b/packages/torouter-web/tui/views/status.html @@ -1 +1,3 @@ -the status page +$def with (content) + +$:content |