test: Update list-known-networks use of DBus API

This commit is contained in:
Andrew Zaborowski 2019-04-11 03:10:19 +02:00 committed by Denis Kenzior
parent ceb605a2cc
commit 9aa2c8dae0
1 changed files with 18 additions and 4 deletions

View File

@ -5,17 +5,31 @@ import dbus
bus = dbus.SystemBus()
kn = dbus.Interface(bus.get_object("net.connman.iwd", "/"),
"net.connman.iwd.KnownNetworks")
manager = dbus.Interface(bus.get_object('net.connman.iwd', '/'),
'org.freedesktop.DBus.ObjectManager')
forget = None
if len(sys.argv) >= 4 and sys.argv[1] == 'forget':
kn.ForgetNetwork(sys.argv[2], sys.argv[3])
forget = (sys.argv[2], sys.argv[3])
print('Known Networks:')
for network in kn.ListKnownNetworks():
for path, interfaces in manager.GetManagedObjects().items():
if 'net.connman.iwd.KnownNetwork' not in interfaces:
continue
network = interfaces['net.connman.iwd.KnownNetwork']
if (network['Name'], network['Type']) == forget:
obj = dbus.Interface(bus.get_object('net.connman.iwd', path),
'net.connman.iwd.KnownNetwork')
obj.Forget()
continue
print("[ %s ]" % network['Name'])
for key in network:
val = network[key]
if type(val) == dbus.Boolean:
val = 'True' if val else 'False'
print(" %s = %s" % (key, val))