Add some extra HTTP body context debug
[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 extract_values(values):
9         val = "{"
10         for key in values.keys():
11                 val += " " + key + "="
12                 if key in ["Servers", "Excludes"]:
13                         val += extract_list(values[key])
14                 else:
15                         val += str(values[key])
16         val += " }"
17         return val
18
19 def extract_list(list):
20         val = "["
21         for i in list:
22                 val += " " + str(i)
23         val += " ]"
24         return val
25
26 def property_changed(name, value, path):
27         service = path[path.rfind("/") + 1:]
28         if name in ["Profiles", "Services", "Providers", "Technologies"]
29                 val = "["
30                 for i in value:
31                         val = val + " " + i[i.rfind("/") + 1:]
32                 val = val + " ]"
33         elif name in ["IPv4", "IPv4.Configuration",
34                         "IPv6", "IPv6.Configuration",
35                         "Proxy", "Proxy.Configuration", "Ethernet"]:
36                 val = extract_values(value)
37         elif name in ["Nameservers", "Nameservers.Configuration",
38                                         "Domains", "Domains.Configuration"]:
39                 val = extract_list(value)
40         elif name in ["Strength", "Priority"]:
41                 val = int(value)
42         else:
43                 val = str(value)
44         print "[%s] %s = %s" % (service, name, val)
45
46 if __name__ == '__main__':
47         dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
48
49         bus = dbus.SystemBus()
50
51         bus.add_signal_receiver(property_changed,
52                                 bus_name="org.moblin.connman",
53                                 dbus_interface="org.moblin.connman.Service",
54                                 signal_name = "PropertyChanged",
55                                 path_keyword="path")
56
57         mainloop = gobject.MainLoop()
58         mainloop.run()