6 def make_variant(string):
7 return dbus.String(string, variant_level=1)
10 print("Usage: %s <service> [off|dhcp|manual <address> [netmask] [gateway]]" % (sys.argv[0]))
13 if (len(sys.argv) < 3):
17 bus = dbus.SystemBus()
18 path = "/net/connman/service/" + sys.argv[1]
19 service = dbus.Interface(bus.get_object('net.connman', path),
20 'net.connman.Service')
22 properties = service.GetProperties()
24 print("Setting method %s for %s" % (sys.argv[2], sys.argv[1]))
26 ipv4_configuration = { "Method": make_variant(sys.argv[2]) }
27 if (len(sys.argv) > 3):
28 ipv4_configuration["Address"] = make_variant(sys.argv[3])
29 if (len(sys.argv) > 4):
30 ipv4_configuration["Netmask"] = make_variant(sys.argv[4])
31 if (len(sys.argv) > 5):
32 ipv4_configuration["Gateway"] = make_variant(sys.argv[5])
34 service.SetProperty("IPv4.Configuration", ipv4_configuration)
35 print("New IPv4.Configuration: ", ipv4_configuration)