Browse Source

fix #10

windows^2
Florian N 12 years ago
parent
commit
96f86840fe
  1. 14
      main/views.py
  2. 2
      usage/views.py

14
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}

2
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):
"""

Loading…
Cancel
Save