service: Remove WPS from the exported D-Bus properties
[platform/upstream/connman.git] / test / test-manager
1 #!/usr/bin/python
2
3 import dbus
4
5 def extract_values(values):
6         val = "{"
7         for key in values.keys():
8                 val += " " + key + "="
9                 if key in ["PrefixLength"]:
10                         val += "%s" % (int(values[key]))
11                 else:
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 bus = dbus.SystemBus()
27
28 manager = dbus.Interface(bus.get_object("net.connman", "/"),
29                                         "net.connman.Manager")
30
31 properties = manager.GetProperties()
32
33 def print_properties(key, value):
34         if key == "Profiles":
35                 interface = "net.connman.Profile"
36         elif key == "Services":
37                 interface = "net.connman.Service"
38         elif key == "Technologies":
39                 interface = "net.connman.Technology"
40         else:
41                 return
42
43         print "%s" % (key)
44         for path in value:
45                 print "    %s" % (path)
46                 obj = dbus.Interface(bus.get_object("net.connman", path),
47                                                                 interface)
48
49                 properties = obj.GetProperties()
50
51                 for key in properties.keys():
52                         if key in ["Services", "Technologies"]:
53                                 continue
54
55                         elif key in ["Powered", "Scanning", "Connected",
56                                         "Available", "Remember", "Default",
57                                         "Favorite", "Immutable", "AutoConnect",
58                                                 "LoginRequired", "SetupRequired",
59                                                 "PassphraseRequired"]:
60                                 if properties[key] == dbus.Boolean(1):
61                                         val = "true"
62                                 else:
63                                         val = "false"
64
65                         elif key in ["IPv4", "IPv4.Configuration",
66                                         "IPv6", "IPv6.Configuration",
67                                                 "Proxy", "Proxy.Configuration",
68                                                         "Ethernet", "Provider"]:
69                                 val = extract_values(properties[key])
70
71                         elif key in ["Nameservers", "Nameservers.Configuration",
72                                         "Domains", "Domains.Configuration",
73                                                 "Security"]:
74                                 val = extract_list(properties[key])
75
76                         elif key in ["Strength", "Priority"]:
77                                 val = int(properties[key])
78
79                         elif key in ["Tethering"]:
80                                 if properties[key] == dbus.Boolean(1):
81                                         val = "true"
82                                 else:
83                                         val = "false"
84                         else:
85                                 val = str(properties[key])
86
87                         print "        %s = %s" % (key, val)
88
89                 if "Services" in properties.keys():
90                         list = ""
91                         for path in properties["Services"]:
92                                 val = str(path)
93                                 list = list + val[val.rfind("/") + 1:] + " "
94                         print "        Services = [ %s]" % (list)
95
96
97 for key in properties.keys():
98         if key in ["Profiles", "Services", "Technologies"]:
99                 print_properties(key, properties[key])
100         elif key in ["AvailableTechnologies", "EnabledTechnologies",
101                                         "ConnectedTechnologies",
102                                 "AvailableDebugs", "EnabledDebugs"]:
103                 print "%s" % (key)
104                 list = ""
105                 for val in properties[key]:
106                         list = list + val + " "
107                 print "    [ %s]" % (list)
108         elif key in ["OfflineMode", "Tethering"]:
109                 print "%s" % (key)
110                 if properties[key] == dbus.Boolean(1):
111                         print "    true"
112                 else:
113                         print "    false"
114         elif key in ["DefaultTechnology"]:
115                 print "%s" % (key)
116                 if properties[key] == "":
117                         print "    <none>"
118                 else:
119                         print "    %s" % (properties[key])
120         else:
121                 print "%s" % (key)
122                 print "    %s" % (properties[key])