1 class MyDBUSService(dbus.service.Object): 2 def __init__(self): 3 bus_name = dbus.service.BusName('org.primerdbus.serviciohola', 4 bus=dbus.SessionBus()) 5 dbus.service.Object.__init__(self, 6 bus_name, 7 '/org/primerdbus/serviciohola') 8 9 @dbus.service.method('org.primerdbus.serviciohola') 10 def hello(self): 11 return "Hello,World!" 12 13 @dbus.service.method('org.primerdbus.serviciohola') 14 def shutdown(self): 15 loop.quit() 16 17 DBusGMainLoop(set_as_default=True) 18 myservice = MyDBUSService() 19 20 loop = GObject.MainLoop() 21 loop.run()