New to D-BUS; signals in Python bindings

Luigi Paioro luigi at
Thu Mar 30 01:24:51 PST 2006


I'm brand-new to DBUS developping and for the time being I'm only doing some 
tests. I have SuSE Linux 10.0 with the default DBUS installed (0.42 I think), 
and I'm trying to make a simple HelloWorldObject program (with Python 
bindings) that puts on the bus this object and emits a signal. Another 
program named HelloWorldCall, listen for this signal and, once it receives 
the notification, prints the signal argument (just a message). Basing on the 
Tutorial, I've written this simple code:

### ###

import gobject
import dbus
import dbus.service

if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
    import dbus.glib

class HelloWorldObject(dbus.service.Object):
    def __init__(self, bus_name, 	
        dbus.service.Object.__init__(self, bus_name, object_path)

    def HelloSignal(self, message):

session_bus = dbus.SessionBus()
bus_name = dbus.service.BusName('org.freedesktop.HelloWorld', bus=session_bus)
object = HelloWorldObject(bus_name)

global i

def emit():
    global i
    object.HelloSignal("Seconds: %d" % i)

gobject.timeout_add(1000, emit)

mainloop = gobject.MainLoop()

### ###

import dbus
import gobject

bus = dbus.SessionBus()

proxy_obj1 = 
iface1 = dbus.Interface(proxy_obj1, 'org.freedesktop.HelloWorldIFace')

def print_message(message):
    print message

iface1.connect_to_signal("HelloSignal", print_message, iface1)

mainloop = gobject.MainLoop()


When I run this code, returns this error:

Traceback (most recent call last):
  File "", line 27, in ?
    iface1.connect_to_signal("HelloSignal", print_message, iface1)
  File "/usr/lib/python2.4/site-packages/dbus/", line 191, in 
    self._obj.connect_to_signal(signal_name, handler_function, dbus_interface)
  File "/usr/lib/python2.4/site-packages/dbus/", line 77, in 
  File "/usr/lib/python2.4/site-packages/dbus/", line 120, in 
    dbus_bindings.bus_add_match(self._connection, str(match_rule))
  File "dbus_bindings.pyx", line 1476, in dbus_bindings.bus_add_match
dbus_bindings.DBusException: Interface name '<Interface <ProxyObject wrapping 
<dbus._dbus.SessionBus instance at 0x403e366c> 
org.freedesktop.HelloWorld /org/freedesktop/HelloWorldObject at 403e37ac> 
implementing org.freedesktop.HelloWorldIFace at 403e3bcc>' is invalid

Well, of course I'm mistaking something, but I don't understand what!

Can you help me, please?

Excuse me for this elementary question...

Thank you in advance.


More information about the dbus mailing list