|
|
Sponsor |
Re: New to D-BUS; signals in Python bindings: msg#00065freedesktop.dbus
Hmm, perhaps we should be able to take an interface as the interface name but in your case you don't need to send the interface name in since you are using the same interface name as the interface itself: class Interface: def connect_to_signal(self, signal_name, handler_function, dbus_interface = None, **keywords): if not dbus_interface: dbus_interface = self._dbus_interface so iface1.connect_to_signal("HelloSignal", print_message) would suffice. Of course you could also do iface1.connect_to_signal("HelloSignal", print_message, 'org.freedesktop.HelloWorldIFace') but that would be redundant. On Thu, 2006-03-30 at 11:24 +0200, Luigi Paioro wrote: > Hello! > > 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: > > ### HelloWorldObject.py ### > > 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, > object_path='/org/freedesktop/HelloWorldObject'): > dbus.service.Object.__init__(self, bus_name, object_path) > > @dbus.service.signal('org.freedesktop.HelloWorldIFace') > def HelloSignal(self, message): > pass > > session_bus = dbus.SessionBus() > bus_name = dbus.service.BusName('org.freedesktop.HelloWorld', bus=session_bus) > object = HelloWorldObject(bus_name) > > global i > i=0 > > def emit(): > global i > i+=1 > object.HelloSignal("Seconds: %d" % i) > > gobject.timeout_add(1000, emit) > > mainloop = gobject.MainLoop() > mainloop.run() > > > ### HelloWorldCall.py ### > > import dbus > import gobject > > bus = dbus.SessionBus() > > proxy_obj1 = > bus.get_object('org.freedesktop.HelloWorld','/org/freedesktop/HelloWorldObject') > 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() > mainloop.run() > > ########## > > When I run this code, HelloWorldCall.py returns this error: > > Traceback (most recent call last): > File "HelloWorldCall.py", line 27, in ? > iface1.connect_to_signal("HelloSignal", print_message, iface1) > File "/usr/lib/python2.4/site-packages/dbus/_dbus.py", line 191, in > connect_to_signal > self._obj.connect_to_signal(signal_name, handler_function, dbus_interface) > File "/usr/lib/python2.4/site-packages/dbus/proxies.py", line 77, in > connect_to_signal > path=self._object_path) > File "/usr/lib/python2.4/site-packages/dbus/_dbus.py", line 120, in > add_signal_receiver > 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. > > Luigi > _______________________________________________ > dbus mailing list > dbus-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@xxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/dbus
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Updated patch, John (J5) Palmieri |
|---|---|
| Next by Date: | Re: Updated patch, Tim Moloney |
| Previous by Thread: | Updated patch, Tim Moloney |
| Next by Thread: | Annotations in Java binding, Tim Moloney |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|