Add support for listing service details
[connman] / test / test-manager
1 #!/usr/bin/python
2
3 import dbus
4
5 bus = dbus.SystemBus()
6
7 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
8                                         "org.moblin.connman.Manager")
9
10 properties = manager.GetProperties()
11
12 def print_properties(key, value):
13         if key == "Profiles":
14                 interface = "org.moblin.connman.Profile"
15         elif key == "Devices":
16                 interface = "org.moblin.connman.Device"
17         elif key == "Connections":
18                 interface = "org.moblin.connman.Connection"
19         elif key == "Services":
20                 interface = "org.moblin.connman.Service"
21         else:
22                 return
23
24         print "%s" % (key)
25         for path in value:
26                 print "    %s" % (path)
27                 obj = dbus.Interface(bus.get_object("org.moblin.connman", path),
28                                                                 interface)
29
30                 properties = obj.GetProperties()
31
32                 for key in properties.keys():
33                         if key in ["Networks", "Services"]:
34                                 continue
35
36                         if key in ["Powered", "Scanning", "Connected",
37                                         "Available", "Remember", "Default"]:
38                                 if properties[key] == dbus.Boolean(1):
39                                         val = "true"
40                                 else:
41                                         val = "false"
42                         elif key in ["Strength", "Priority"]:
43                                 val = int(properties[key])
44                         else:
45                                 val = str(properties[key])
46
47                         print "        %s = %s" % (key, val)
48
49                 if "Networks" in properties.keys():
50                         list = ""
51                         for path in properties["Networks"]:
52                                 val = str(path)
53                                 list = list + val[val.rfind("/") + 1:] + " "
54                         print "        Networks = [ %s]" % (list)
55                 if "Services" in properties.keys():
56                         list = ""
57                         for path in properties["Services"]:
58                                 val = str(path)
59                                 list = list + val[val.rfind("/") + 1:] + " "
60                         print "        Services = [ %s]" % (list)
61
62 for key in properties.keys():
63         if key in ["Profiles", "Devices", "Connections", "Services"]:
64                 print_properties(key, properties[key])
65         elif key in ["OfflineMode"]:
66                 print "%s" % (key)
67                 if properties[key] == dbus.Boolean(1):
68                         print "    true"
69                 else:
70                         print "    false"
71         else:
72                 print "%s" % (key)
73                 print "    %s" % (properties[key])