Raise an error with a python object
Luigi Paioro
luigi at lambrate.inaf.it
Fri May 12 06:56:55 PDT 2006
Hi!
I have an object put on the bus which has a method that can raise
errors. How can I handle such situation? I've read that I have to use a
dbus.Error object, can anybody send me an example?
For example, suppose I have something like this:
#!/usr/bin/python
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.method('org.freedesktop.HelloWorldIFace')
def hello(self, flag):
if not flag:
# TODO: RAISE AN ERROR
return 'Hello from the HelloWorldObject'
session_bus = dbus.SessionBus()
bus_name = dbus.service.BusName('org.freedesktop.HelloWorld',
bus=session_bus)
object = HelloWorldObject(bus_name)
mainloop = gobject.MainLoop()
mainloop.run()
How can I fix it?
Thanks in advance.
Luigi
More information about the dbus
mailing list