test: WPS input added in agent test script
[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", "WPS"]:
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                                 val = extract_list(properties[key])
74
75                         elif key in ["Strength", "Priority"]:
76                                 val = int(properties[key])
77                         else:
78                                 val = str(properties[key])
79
80                         print "        %s = %s" % (key, val)
81
82                 if "Services" in properties.keys():
83                         list = ""
84                         for path in properties["Services"]:
85                                 val = str(path)
86                                 list = list + val[val.rfind("/") + 1:] + " "
87                         print "        Services = [ %s]" % (list)
88
89
90 for key in properties.keys():
91         if key in ["Profiles", "Services", "Technologies"]:
92                 print_properties(key, properties[key])
93         elif key in ["AvailableTechnologies", "EnabledTechnologies",
94                                         "ConnectedTechnologies",
95                                 "AvailableDebugs", "EnabledDebugs"]:
96                 print "%s" % (key)
97                 list = ""
98                 for val in properties[key]:
99                         list = list + val + " "
100                 print "    [ %s]" % (list)
101         elif key in ["OfflineMode", "Tethering"]:
102                 print "%s" % (key)
103                 if properties[key] == dbus.Boolean(1):
104                         print "    true"
105                 else:
106                         print "    false"
107         elif key in ["DefaultTechnology"]:
108                 print "%s" % (key)
109                 if properties[key] == "":
110                         print "    <none>"
111                 else:
112                         print "    %s" % (properties[key])
113         else:
114                 print "%s" % (key)
115                 print "    %s" % (properties[key])