1#!/usr/bin/python 2import dbus 3 4bus = dbus.SystemBus() 5p = bus.get_object("uk.org.thekelleys.dnsmasq", "/uk/org/thekelleys/dnsmasq") 6l = dbus.Interface(p, dbus_interface="uk.org.thekelleys.dnsmasq") 7 8# The new more flexible SetServersEx method 9array = dbus.Array() 10array.append(["1.2.3.5"]) 11array.append(["1.2.3.4#664", "foobar.com"]) 12array.append(["1003:1234:abcd::1%eth0", "eng.mycorp.com", "lab.mycorp.com"]) 13print l.SetServersEx(array) 14 15# Must create a new object for dnsmasq as the introspection gives the wrong 16# signature for SetServers (av) while the code only expects a bunch of arguments 17# instead of an array of variants 18p = bus.get_object("uk.org.thekelleys.dnsmasq", "/uk/org/thekelleys/dnsmasq", introspect=False) 19l = dbus.Interface(p, dbus_interface="uk.org.thekelleys.dnsmasq") 20 21# The previous method; all addresses in machine byte order 22print l.SetServers(dbus.UInt32(16909060), # 1.2.3.5 23 dbus.UInt32(16909061), # 1.2.3.4 24 "foobar.com", 25 dbus.Byte(0x10), # 1003:1234:abcd::1 26 dbus.Byte(0x03), 27 dbus.Byte(0x12), 28 dbus.Byte(0x34), 29 dbus.Byte(0xab), 30 dbus.Byte(0xcd), 31 dbus.Byte(0x00), 32 dbus.Byte(0x00), 33 dbus.Byte(0x00), 34 dbus.Byte(0x00), 35 dbus.Byte(0x00), 36 dbus.Byte(0x00), 37 dbus.Byte(0x00), 38 dbus.Byte(0x00), 39 dbus.Byte(0x00), 40 dbus.Byte(0x01), 41 "eng.mycorp.com", 42 "lab.mycorp.com") 43 44