6 def make_variant(string):
7 return dbus.String(string, variant_level=1)
9 def extract_values(values):
11 for key in values.keys():
12 val += " " + key + "="
13 if key in ["Servers", "Excludes"]:
14 val += extract_list(values[key])
16 val += str(values[key])
20 def extract_list(list):
23 if type(i).__name__ == 'Dictionary':
24 val += extract_values(i)
25 elif type(i).__name__ == 'Struct':
26 val += extract_list(i)
35 print "Usage: %s <VPN connection id> [<property name>] [<property values>]" % (sys.argv[0])
38 bus = dbus.SystemBus()
40 manager = dbus.Interface(bus.get_object("net.connman.vpn", "/"),
41 "net.connman.vpn.Manager")
43 connections = manager.GetConnections()
45 path = "/net/connman/vpn/connection/" + sys.argv[1]
47 print "Attempting to connect VPN %s" % (path)
49 connection = dbus.Interface(bus.get_object("net.connman.vpn", path),
50 "net.connman.vpn.Connection")
53 properties = connection.GetProperties()
54 for key in properties.keys():
55 if key in ["IPv4", "IPv6" ]:
56 val = extract_values(properties[key])
57 elif key in ["Nameservers","ServerRoutes","UserRoutes"]:
58 val = extract_list(properties[key])
60 val = str(properties[key])
61 print " %s = %s" % (key, val)
65 connection.ClearProperty(sys.argv[2])
66 except dbus.DBusException, error:
67 print "%s: %s" % (error._dbus_error_name, error.message)
70 connection.SetProperty(sys.argv[2], sys.argv[3])
71 except dbus.DBusException, error:
72 print "%s: %s" % (error._dbus_error_name, error.message)