From 96f86840fec4b353c57bc4879198c9b685052773 Mon Sep 17 00:00:00 2001 From: Florian N Date: Mon, 17 Feb 2014 13:41:11 -0500 Subject: [PATCH] fix #10 --- main/views.py | 14 +++++++------- usage/views.py | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/main/views.py b/main/views.py index b59f2d6..096f54a 100755 --- a/main/views.py +++ b/main/views.py @@ -71,16 +71,16 @@ def get_ipaddress(): Get the IP Address """ try: - pipe = os.popen(" ip addr | grep -A3 'state UP' | awk '{printf \"%s,\",$2}'|awk -F, '{print $1, $2, $3}'") - data = pipe.read().strip().split('\n') + pipe = os.popen(" ip addr | grep -A3 'UP' | awk '{printf \"%s,\",$2}'|awk -F,, '{print $1, $2, $3}'") + data = pipe.read().strip().split(' ') pipe.close() - data = [i.split(None, 3) for i in data] + data = [n for n in data if not n.startswith(('lo', '127'))] + data = [i.split(',', 3) for i in data] + + itf = [] for e in data: - if len(e) > 3: - itf = dict(zip([iter(e[0].strip(':'))])) - else: - itf = [e[0].strip(':')] + itf.append(e[0].strip(':')) ips = {'interface': itf, 'itfip': data} diff --git a/usage/views.py b/usage/views.py index 79b23d5..dc53442 100755 --- a/usage/views.py +++ b/usage/views.py @@ -33,6 +33,7 @@ time_refresh = TIME_JS_REFRESH time_refresh_long = TIME_JS_REFRESH_LONG time_refresh_net = TIME_JS_REFRESH_NET + @login_required(login_url='/login/') def getnetstat(request): """ @@ -49,6 +50,7 @@ def getnetstat(request): response.write(data) return response + @login_required(login_url='/login/') def uptime(request): """