Add support for setting proxy configuration method
[framework/connectivity/connman.git] / test / list-services
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                         val += str(values[key])
13         val += " }"
14         return val
15
16 def extract_list(list):
17         val = "["
18         for i in list:
19                 val += " " + str(i)
20         val += " ]"
21         return val
22
23 bus = dbus.SystemBus()
24
25 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
26                                         "org.moblin.connman.Manager")
27
28 properties = manager.GetProperties()
29
30 for path in properties["Services"]:
31         service = dbus.Interface(bus.get_object("org.moblin.connman", path),
32                                                 "org.moblin.connman.Service")
33
34         properties = service.GetProperties()
35
36         print "[ %s ]" % (path)
37
38         for key in properties.keys():
39                 if key in ["IPv4", "IPv4.Configuration",
40                                 "IPv6", "IPv6.Configuration",
41                                         "Proxy", "Proxy.Configuration",
42                                                 "Ethernet", "Provider"]:
43                         val = extract_values(properties[key])
44                 elif key in ["Nameservers", "Nameservers.Configuration",
45                                         "Domains", "Domains.Configuration"]:
46                         val = extract_list(properties[key])
47                 elif key in ["Favorite", "Immutable", "AutoConnect",
48                                         "LoginRequired", "SetupRequired",
49                                                         "PassphraseRequired"]:
50                         if properties[key] == dbus.Boolean(1):
51                                 val = "true"
52                         else:
53                                 val = "false"
54                 elif key in ["Strength"]:
55                         val = int(properties[key])
56                 else:
57                         val = properties[key]
58                 print "    %s = %s" % (key, val)
59
60         print