#! /usr/bin/python
import dbus
# Obtain proxy to the '/org/me/test' object living in connection 'org.me'
obj = dbus.SessionBus().get_object('org.me', '/org/me/test')
# Invoke object's hi() method. A special parameter dbus_interface specifies
# which interface defines the method. There are other ways of naming the
# interface, but I'm told they are really obsolete.
# The return value for hi() arrives from the object as if this were a local
# method invocation.
print obj.hi(dbus_interface='org.me.HelloInterface')
# This method raises an exception on the other end, which is also translated
# to a normal exception on our end.
try:
obj.fail(dbus_interface='org.me.HelloInterface')
except Exception, e:
print str(e)