Python DBus - Creating A Service

John (J5) Palmieri johnp at redhat.com
Wed Feb 6 14:22:04 PST 2008


On Wed, 2008-02-06 at 16:50 +0000, Robert Rawlins wrote:
> 
> 
> 
> 
>         
>         ______________________________________________________________
>         
>         From: robert_rawlins at hotmail.com
>         To: dbus at lists.freedesktop.org
>         Subject: RE: Python DBus - Creating A Service
>         Date: Wed, 6 Feb 2008 16:13:38 +0000
>         
>         > On Wed, 2008-02-06 at 15:47 +0000, Robert Rawlins wrote:
>         > > Hello Guys,
>         > > 
>         > > I hope this is the right place to ask my question,
>         apologies if I
>         > > should be on another list, please feel free to point me in
>         the right
>         > > direction if that is the case. I'm new to dbus, I've been
>         using it for
>         > > a little while consuming other peoples services and things
>         like that.
>         > > 
>         > > Today I've started working on my own service, however I'm
>         struggling a
>         > > little to get it working. I've been using the following
>         example code
>         > > to try and get a service running on my system
>         > > http://paste.lisp.org/display/45824 however when I attempt
>         to run this
>         > > python script I get the following error:
>         > > 
>         > > File "TestService.py", line 15, in ?
>         > > myservice = MyDBUSService()
>         > > File "TestService.py", line 7, in __init__
>         > > bus_name =
>         dbus.service.BusName('org.frankhale.helloservice',
>         > > bus=dbus.SessionBus())
>         > > File "/var/lib/python-support/python2.4/dbus/_dbus.py",
>         line 217, in
>         > > __new__
>         > > mainloop=mainloop)
>         > > File "/var/lib/python-support/python2.4/dbus/_dbus.py",
>         line 106, in
>         > > __new__
>         > > bus = BusConnection.__new__(subclass, bus_type,
>         mainloop=mainloop)
>         > > File "/var/lib/python-support/python2.4/dbus/bus.py", line
>         125, in
>         > > __new__
>         > > bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
>         > > dbus.exceptions.DBusException:
>         > > org.freedesktop.DBus.Error.Spawn.ExecFailed: Failed to
>         execute
>         > > dbus-launch to autolaunch D-Bus session
>         > > 
>         > > Does anyone have any ideas as to why I'm getting this
>         error message?
>         > > 
>         > > Thanks guys, I appreciate any help you can offer.
>         > > 
>         > > Rob
>         > > 
>         > You don't have a bus running and the library can't find
>         dbus-launch to
>         > autostart one.
>         > 
>         > -- 
>         > John (J5) Palmieri <johnp at redhat.com>
>         > 
>          
>         > Hi John,
>          
>         > Thanks for getting back to me mate, I appreciate it. I could
>         use a little more help though. How can I start a bus? or how
>         can I get the library to find > the functions it needs to auto
>         start one?
>         > Sorry for the n00bish questions, this is all new ground for
>         me.
>         > Thanks John,
>         > Rob
>          
>         John, as a quick update, I've just installed a package on my
>         system called dbus-x11 which appears to contrain dbus-launch,
>         however I'm now recieving a slightly different error message:
>          
>         dbus.exceptions.DBusException:
>         org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch
>         failed to autolaunch D-Bus session: Autolaunch error: X11
>         initialization failed.
>         
>         Thanks,
>          
>         Rob 

Are you running in X?  If not you should start a session bus yourself by
running: 

dbus-daemon --session --print-address --print-pid

You then need to set DBUS_SESSION_BUS_ADDRESS= to whatever socket the
daemon output.  A session bus is usually attached to an X session
though.  Most command line tools and system daemons communicate over the
system bus which is usually started at boot by an init script.  

-- 
John (J5) Palmieri <johnp at redhat.com>



More information about the dbus mailing list