• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2
3import gobject
4
5import dbus
6import dbus.mainloop.glib
7
8def property_changed(name, value, path, interface):
9    iface = interface[interface.rfind(".") + 1:]
10    ipath = path[path.rfind("/") + 1:]
11    if iface not in ["Service"]:
12        return
13    if name in ["Profiles", "Services",
14                "Devices", "Networks"]:
15        val = "["
16        for i in value:
17            val = val + " " + i[i.rfind("/") + 1:]
18        val = val + " ]"
19    elif name in ["Strength", "Priority"]:
20        val = int(value)
21    else:
22        val = str(value)
23    print "{%s} [%s] %s = %s" % (iface, ipath, name, val)
24
25if __name__ == '__main__':
26    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
27
28    bus = dbus.SystemBus()
29
30    bus.add_signal_receiver(property_changed,
31                            bus_name="org.chromium.flimflam",
32                            signal_name = "PropertyChanged",
33                            path_keyword="path",
34                            interface_keyword="interface")
35
36    mainloop = gobject.MainLoop()
37    mainloop.run()
38