1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/usr/bin/python
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
def element_print(action, path):
print "%s [ %s ]" % (action, path)
if (action == "-"):
return
element = dbus.Interface(bus.get_object("org.moblin.connman", path),
"org.moblin.connman.Element")
properties = element.GetProperties()
if (properties["Type"] != "network"):
return
for key in properties.keys():
print " %s = %s" % (key, properties[key])
def element_added(path):
element_print("+", path)
def element_updated(path):
element_print("*", path)
def element_removed(path):
element_print("-", path)
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(element_added,
dbus_interface = "org.moblin.connman.Manager",
signal_name = "ElementAdded")
bus.add_signal_receiver(element_updated,
dbus_interface = "org.moblin.connman.Manager",
signal_name = "ElementUpdated")
bus.add_signal_receiver(element_removed,
dbus_interface = "org.moblin.connman.Manager",
signal_name = "ElementRemoved")
mainloop = gobject.MainLoop()
mainloop.run()
|