test: report InterfacesAdded & InterfacesRemoved

This commit is contained in:
Denis Kenzior 2016-09-13 21:42:30 -05:00
parent e14045442a
commit 5b123e1a3d
1 changed files with 30 additions and 0 deletions

View File

@ -56,6 +56,28 @@ def property_changed(name, value, path, interface):
iface = interface[interface.rfind(".") + 1:]
print("{%s} [%s] %s = %s" % (iface, path, name, pretty(value)))
relevant_ifaces = [ "net.connman.iwd.Device",
"net.connman.iwd.Adapter",
"net.connman.iwd.WiFiSimpleConfiguration",
"net.connman.iwd.Network" ]
def interfaces_added(path, interfaces):
for iface, props in interfaces.items():
if not(iface in relevant_ifaces):
continue
print("{Added %s} [%s]" % (iface, path))
for name, value in props.items():
print(" %s = %s" % (name, pretty(value)))
def interfaces_removed(path, interfaces):
for iface in interfaces:
if not(iface in relevant_ifaces):
continue
print("{Removed %s} [%s]" % (iface, path))
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@ -67,5 +89,13 @@ if __name__ == '__main__':
path_keyword="path",
interface_keyword="interface")
bus.add_signal_receiver(interfaces_added, bus_name="net.connman.iwd",
dbus_interface="org.freedesktop.DBus.ObjectManager",
signal_name="InterfacesAdded")
bus.add_signal_receiver(interfaces_removed, bus_name="net.connman.iwd",
dbus_interface="org.freedesktop.DBus.ObjectManager",
signal_name="InterfacesRemoved")
mainloop = GLib.MainLoop()
mainloop.run()