test: Remove provision service
[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 for key in properties.keys():
34         if key in ["AvailableDebugs", "EnabledDebugs"]:
35                 print "%s" % (key)
36                 list = ""
37                 for val in properties[key]:
38                         list = list + val + " "
39                 print "    [ %s]" % (list)
40         elif key in ["OfflineMode", "SessionMode"]:
41                 print "%s" % (key)
42                 if properties[key] == dbus.Boolean(1):
43                         print "    true"
44                 else:
45                         print "    false"
46         else:
47                 print "%s" % (key)
48                 print "    %s" % (properties[key])
49
50 print ("Services")
51 services = manager.GetServices()
52
53 for (path, properties) in services:
54         print "    %s" % (path)
55         for key in properties.keys():
56                 if key in ["Available", "Remember", "Default",
57                                 "Favorite", "Immutable", "AutoConnect",
58                                         "LoginRequired",
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                 else:
80                         val = str(properties[key])
81
82                 print "        %s = %s" % (key, val)
83
84 print ("Technologies")
85 technologies = manager.GetTechnologies()
86
87 for (path, properties) in technologies:
88         print "    %s" % (path)
89         for key in properties.keys():
90
91                 if key in ["Connected", "Powered", "Tethering"]:
92                         if properties[key] == dbus.Boolean(1):
93                                 val = "true"
94                         else:
95                                 val = "false"
96                 else:
97                         val = properties[key]
98
99                 print "        %s = %s" % (key, val)