Fix wrong return type of LookupService message
[platform/upstream/connman.git] / 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 == "Services":
18                 interface = "org.moblin.connman.Service"
19         elif key == "Providers":
20                 interface = "org.moblin.connman.Provider"
21         elif key == "Technologies":
22                 interface = "org.moblin.connman.Technology"
23         else:
24                 return
25
26         print "%s" % (key)
27         for path in value:
28                 print "    %s" % (path)
29                 obj = dbus.Interface(bus.get_object("org.moblin.connman", path),
30                                                                 interface)
31
32                 properties = obj.GetProperties()
33
34                 for key in properties.keys():
35                         if key in ["Devices", "Networks", "Services",
36                                                 "Providers", "Technologies"]:
37                                 continue
38
39                         if key in ["Powered", "Scanning", "Connected",
40                                         "Available", "Remember", "Default"]:
41                                 if properties[key] == dbus.Boolean(1):
42                                         val = "true"
43                                 else:
44                                         val = "false"
45                         elif key in ["Strength", "Priority"]:
46                                 val = int(properties[key])
47                         else:
48                                 val = str(properties[key])
49
50                         print "        %s = %s" % (key, val)
51
52                 if "Devices" in properties.keys():
53                         list = ""
54                         for path in properties["Devices"]:
55                                 val = str(path)
56                                 list = list + val[val.rfind("/") + 1:] + " "
57                         print "        Devices = [ %s]" % (list)
58                 if "Networks" in properties.keys():
59                         list = ""
60                         for path in properties["Networks"]:
61                                 val = str(path)
62                                 list = list + val[val.rfind("/") + 1:] + " "
63                         print "        Networks = [ %s]" % (list)
64                 if "Services" in properties.keys():
65                         list = ""
66                         for path in properties["Services"]:
67                                 val = str(path)
68                                 list = list + val[val.rfind("/") + 1:] + " "
69                         print "        Services = [ %s]" % (list)
70                 if "Providers" in properties.keys():
71                         list = ""
72                         for path in properties["Providers"]:
73                                 val = str(path)
74                                 list = list + val[val.rfind("/") + 1:] + " "
75                         print "        Providers = [ %s]" % (list)
76
77
78 for key in properties.keys():
79         if key in ["Profiles", "Devices", "Services", "Providers",
80                                                         "Technologies"]:
81                 print_properties(key, properties[key])
82         elif key in ["AvailableTechnologies", "EnabledTechnologies",
83                                         "ConnectedTechnologies",
84                                 "AvailableDebugs", "EnabledDebugs"]:
85                 print "%s" % (key)
86                 list = ""
87                 for val in properties[key]:
88                         list = list + val + " "
89                 print "    [ %s]" % (list)
90         elif key in ["OfflineMode"]:
91                 print "%s" % (key)
92                 if properties[key] == dbus.Boolean(1):
93                         print "    true"
94                 else:
95                         print "    false"
96         elif key in ["DefaultTechnology"]:
97                 print "%s" % (key)
98                 if properties[key] == "":
99                         print "    <none>"
100                 else:
101                         print "    %s" % (properties[key])
102         else:
103                 print "%s" % (key)
104                 print "    %s" % (properties[key])