Add a special test script to monitor service related signals
[framework/connectivity/connman.git] / test / monitor-services
1 #!/usr/bin/python
2
3 import gobject
4
5 import dbus
6 import dbus.mainloop.glib
7
8 def property_changed(name, value, path, interface):
9         iface = interface[interface.rfind(".") + 1:]
10         if iface not in ["Manager", "Service"]:
11                 return
12         if name in ["Profiles", "Services",
13                                 "Devices", "Networks", "Connections"]:
14                 val = "["
15                 for i in value:
16                         val = val + " " + i[i.rfind("/") + 1:]
17                 val = val + " ]"
18         elif name in ["Strength", "Priority"]:
19                 val = int(value)
20         else:
21                 val = str(value)
22         print "{%s} [%s] %s = %s" % (iface, path, name, val)
23
24 if __name__ == '__main__':
25         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
26
27         bus = dbus.SystemBus()
28
29         bus.add_signal_receiver(property_changed,
30                                         bus_name="org.moblin.connman",
31                                         signal_name = "PropertyChanged",
32                                                 path_keyword="path",
33                                                 interface_keyword="interface")
34
35         mainloop = gobject.MainLoop()
36         mainloop.run()