Permalink
Browse files

display more information about the network interfaces

  • Loading branch information...
1 parent a4f44c1 commit 2958d7e977def7c05c00165400aef4cf81451c20 @Geal committed Mar 18, 2013
Showing with 11 additions and 3 deletions.
  1. +11 −3 network/network
View
14 network/network
@@ -6,20 +6,28 @@ except ImportError:
exit()
def command_from_interface(intf):
- return '{ "name" : "' + intf + '", "value" : "'+ netifaces.ifaddresses(intf)[netifaces.AF_INET][0]["addr"] + '", "command" : ".pilotssh/network/network ' + intf + '" }'
+ ifaddresses = netifaces.ifaddresses(intf)
+ result = []
+ for key in ifaddresses.keys():
+ info = ifaddresses[key]
+ for index in info:
+ result.append('{ "name" : "' + intf + '", "value" : "'+ index["addr"] + '", "command" : ".pilotssh/network/network.py ' + intf + '" }')
+ return result
def index():
result = '{ "version": 1, "title": "Network Interfaces", "type":"commands", "values" : [ '
interfaces = netifaces.interfaces()
length = len(interfaces)
+ res = []
if(length >= 1):
- result += command_from_interface(interfaces[0])
+ res += command_from_interface(interfaces[0])
if(length > 1):
for i in xrange(1, length):
- result += ', ' + command_from_interface(interfaces[i])
+ res += command_from_interface(interfaces[i])
+ result += ', '.join(res)
result += ' ] }'
print result

0 comments on commit 2958d7e

Please sign in to comment.