File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / dnsmasq / contrib / dbus-test / dbus-test.py
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 29 19:37:40 2013 UTC (11 years ago) by misho
Branches: elwix, dnsmasq, MAIN
CVS tags: v8_2p1, v2_84, v2_76p1, v2_71, v2_66p0, v2_66, HEAD
dnsmasq

    1: #!/usr/bin/python
    2: import dbus
    3: 
    4: bus = dbus.SystemBus()
    5: p = bus.get_object("uk.org.thekelleys.dnsmasq", "/uk/org/thekelleys/dnsmasq")
    6: l = dbus.Interface(p, dbus_interface="uk.org.thekelleys.dnsmasq")
    7: 
    8: # The new more flexible SetServersEx method
    9: array = dbus.Array()
   10: array.append(["1.2.3.5"])
   11: array.append(["1.2.3.4#664", "foobar.com"])
   12: array.append(["1003:1234:abcd::1%eth0", "eng.mycorp.com", "lab.mycorp.com"])
   13: print 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
   18: p = bus.get_object("uk.org.thekelleys.dnsmasq", "/uk/org/thekelleys/dnsmasq", introspect=False)
   19: l = dbus.Interface(p, dbus_interface="uk.org.thekelleys.dnsmasq")
   20: 
   21: # The previous method; all addresses in machine byte order
   22: print 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: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>