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"]:
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",
74 val = extract_list(properties[key])
76 elif key in ["Strength", "Priority"]:
77 val = int(properties[key])
79 elif key in ["Tethering"]:
80 if properties[key] == dbus.Boolean(1):
85 val = str(properties[key])
87 print " %s = %s" % (key, val)
89 if "Services" in properties.keys():
91 for path in properties["Services"]:
93 list = list + val[val.rfind("/") + 1:] + " "
94 print " Services = [ %s]" % (list)
97 for key in properties.keys():
98 if key in ["Profiles", "Services", "Technologies"]:
99 print_properties(key, properties[key])
100 elif key in ["AvailableTechnologies", "EnabledTechnologies",
101 "ConnectedTechnologies",
102 "AvailableDebugs", "EnabledDebugs"]:
105 for val in properties[key]:
106 list = list + val + " "
107 print " [ %s]" % (list)
108 elif key in ["OfflineMode", "Tethering"]:
110 if properties[key] == dbus.Boolean(1):
114 elif key in ["DefaultTechnology"]:
116 if properties[key] == "":
119 print " %s" % (properties[key])
122 print " %s" % (properties[key])