2016-07-14 02:38:08 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import dbus
|
|
|
|
|
|
|
|
bus = dbus.SystemBus()
|
|
|
|
|
2019-04-11 03:10:19 +02:00
|
|
|
manager = dbus.Interface(bus.get_object('net.connman.iwd', '/'),
|
|
|
|
'org.freedesktop.DBus.ObjectManager')
|
2016-07-14 02:38:08 +02:00
|
|
|
|
2019-04-11 03:10:19 +02:00
|
|
|
forget = None
|
2016-07-14 02:38:08 +02:00
|
|
|
if len(sys.argv) >= 4 and sys.argv[1] == 'forget':
|
2019-04-11 03:10:19 +02:00
|
|
|
forget = (sys.argv[2], sys.argv[3])
|
2016-07-14 02:38:08 +02:00
|
|
|
|
|
|
|
print('Known Networks:')
|
|
|
|
|
2019-04-11 03:10:19 +02:00
|
|
|
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
|
|
|
|
|
2016-07-14 02:38:08 +02:00
|
|
|
print("[ %s ]" % network['Name'])
|
|
|
|
|
|
|
|
for key in network:
|
|
|
|
val = network[key]
|
2019-04-11 03:10:19 +02:00
|
|
|
if type(val) == dbus.Boolean:
|
|
|
|
val = 'True' if val else 'False'
|
2016-07-14 02:38:08 +02:00
|
|
|
print(" %s = %s" % (key, val))
|