3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-20 19:12:33 +01:00
iwd/test/list-known-networks
2019-04-11 11:01:33 -05:00

36 lines
961 B
Python
Executable File

#!/usr/bin/python3
import sys
import dbus
bus = dbus.SystemBus()
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':
forget = (sys.argv[2], sys.argv[3])
print('Known Networks:')
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))