3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-20 19:12:33 +01:00

test: Show Adapter properties in list-devices

This commit is contained in:
Andrew Zaborowski 2016-07-26 14:42:57 +02:00 committed by Denis Kenzior
parent d362ce83b9
commit 55f8942d8f

View File

@ -2,6 +2,7 @@
import sys import sys
import dbus import dbus
import collections
bus = dbus.SystemBus() bus = dbus.SystemBus()
@ -9,24 +10,49 @@ manager = dbus.Interface(bus.get_object("net.connman.iwd", "/"),
"org.freedesktop.DBus.ObjectManager") "org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects() objects = manager.GetManagedObjects()
Obj = collections.namedtuple('Obj', ['interfaces', 'children'])
tree = Obj({}, {})
for path in objects: for path in objects:
if 'net.connman.iwd.Device' not in objects[path]: node = tree
elems = path.split('/')
for subpath in [ '/'.join(elems[:l + 1]) for l in range(1, len(elems)) ]:
if subpath not in node.children:
node.children[subpath] = Obj({}, {})
node = node.children[subpath]
node.interfaces.update(objects[path])
for path, phy in tree.children.items():
if 'net.connman.iwd.Adapter' not in phy.interfaces:
continue continue
properties = objects[path]['net.connman.iwd.Device'] properties = phy.interfaces['net.connman.iwd.Adapter']
device = dbus.Interface(bus.get_object("net.connman.iwd", path),
'net.connman.iwd.Device')
print("[ %s ]" % path) print("[ %s ]" % path)
for key in properties:
val = properties[key]
print(" %s = %s" % (key, val))
print(" Devices:")
for path2, device in phy.children.items():
if 'net.connman.iwd.Device' not in device.interfaces:
continue
properties = device.interfaces['net.connman.iwd.Device']
device = dbus.Interface(bus.get_object("net.connman.iwd", path2),
'net.connman.iwd.Device')
print(" [ %s ]" % path2)
for key in properties: for key in properties:
val = properties[key] val = properties[key]
print(" %s = %s" % (key, val)) print(" %s = %s" % (key, val))
print(" Sorted networks:") print(" Sorted networks:")
for path2, ssid, rssi, security in device.GetOrderedNetworks(): for path3, ssid, rssi, security in device.GetOrderedNetworks():
print(" [ %s ]" % path2) print(" [ %s ]" % path3)
print(" SSID = %s" % (ssid,)) print(" SSID = %s" % (ssid,))
print(" Signal strength = %i dBm" % (rssi / 100,)) print(" Signal strength = %i dBm" % (rssi / 100,))