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