Vizible’s Blog

Simple DBus App

Posted in Programming by wearetherock on January 24, 2009

import dbus
import dbus.service
import dbus.mainloop.glib
import gobject

class Test(dbus.service.Object):
  @dbus.service.method("com.example.MyInterface",in_signature="", out_signature="s")
  def hello_world(self):
    return 'Hello, world'
if __name__ == '__main__' :
  session_bus = dbus.SessionBus()
  name = dbus.service.BusName("com.example.MyName", session_bus)
  object = Test(session_bus, '/MyObject', name)
  mainloop = gobject.MainLoop()
  print 'Running service ...'

import dbus

bus = dbus.SessionBus()
remote_object = bus.get_object("com.example.MyName",
test = dbus.Interface( remote_object, "com.example.MyInterface")
text = test.hello_world()
print text
Tagged with:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: