Activation
Luigi Paioro
luigi at lambrate.inaf.it
Tue Jan 16 09:08:10 PST 2007
Hello!
I think I've not understood well how .service files work.
I've created a server script (HelloTestServer.py) which provides a
simple object:
<code>
#!/usr/bin/python
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
class HelloWorldObject(dbus.service.Object):
def __init__(self, bus_name,
object_path='/org/freedesktop/HelloWorld'):
dbus.service.Object.__init__(self, bus_name, object_path)
@dbus.service.method('org.freedesktop.HelloWorldIFace')
def hello(self):
print "Hello world!"
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
session_bus = dbus.SessionBus()
bus_name = dbus.service.BusName('org.freedesktop.HelloWorld',
bus=session_bus)
object = HelloWorldObject(bus_name)
mainloop = gobject.MainLoop()
mainloop.run()
</code>
So I've created under <prefix>/share/dbus-1/services (I've got a custom
D-Bus installation) the file hello.service:
<code>
[D-BUS Service]
Names=org.freedesktop.HelloWorld
Exec=<where_is_my_program>/HelloTestServer.py
</code>
Then I've started my D-Bus session:
csh > dbus-launch --csh-syntax
csh > setenv DBUS_SESSION_BUS_ADDRESS
'unix:abstract=/tmp/dbus-mcynDScyts,guid=5ff550ed59db81f96327200045acff2e';
And then I've tried to connect to my object:
csh > python
Python 2.4.1 (#1, Sep 13 2005, 00:39:20)
[GCC 4.0.2 20050901 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> import dbus.mainloop.glib
>>> dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
<dbus.mainloop.NativeMainLoop object at 0x4028a860>
>>> session_bus = dbus.SessionBus()
>>> o = session_bus.get_object('org.freedesktop.HelloWorld',
'/org/freedesktop/HelloWorld')
>>> i=dbus.Interface(o, 'org.freedesktop.HelloWorldIFace')
>>> i.hello()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<prefix>/lib/python2.4/site-packages/dbus/proxies.py", line
161, in __call__
reply_message =
self._connection.send_message_with_reply_and_block(message, timeout)
dbus.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name
org.freedesktop.HelloWorld was not provided by any .service files
My configuration:
dbus-1.0.2
dbus-glib-0.72
dbus-python-0.79.93
Please, can you explain me one more time how can I configure the D-Bus
activation?
Thank you very much.
Luigi
More information about the dbus
mailing list