5 def extract_values(values):
7 for key in values.keys():
9 if key in ["PrefixLength"]:
10 val += "%s" % (int(values[key]))
12 if key in ["Servers", "Excludes"]:
13 val += extract_list(values[key])
15 val += str(values[key])
19 def extract_list(list):
26 bus = dbus.SystemBus()
28 manager = dbus.Interface(bus.get_object("net.connman", "/"),
29 "net.connman.Manager")
31 properties = manager.GetProperties()
33 def print_properties(key, value):
35 interface = "net.connman.Profile"
36 elif key == "Services":
37 interface = "net.connman.Service"
38 elif key == "Technologies":
39 interface = "net.connman.Technology"
46 obj = dbus.Interface(bus.get_object("net.connman", path),
49 properties = obj.GetProperties()
51 for key in properties.keys():
52 if key in ["Services", "Technologies"]:
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):
65 elif key in ["IPv4", "IPv4.Configuration",
66 "IPv6", "IPv6.Configuration",
67 "Proxy", "Proxy.Configuration",
68 "Ethernet", "Provider"]:
69 val = extract_values(properties[key])
71 elif key in ["Nameservers", "Nameservers.Configuration",
72 "Domains", "Domains.Configuration"]:
73 val = extract_list(properties[key])
75 elif key in ["Strength", "Priority"]:
76 val = int(properties[key])
78 val = str(properties[key])
80 print " %s = %s" % (key, val)
82 if "Services" in properties.keys():
84 for path in properties["Services"]:
86 list = list + val[val.rfind("/") + 1:] + " "
87 print " Services = [ %s]" % (list)
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"]:
98 for val in properties[key]:
99 list = list + val + " "
100 print " [ %s]" % (list)
101 elif key in ["OfflineMode", "Tethering"]:
103 if properties[key] == dbus.Boolean(1):
107 elif key in ["DefaultTechnology"]:
109 if properties[key] == "":
112 print " %s" % (properties[key])
115 print " %s" % (properties[key])