Paste number 45824: python dbus example

Paste number 45824: python dbus example
Pasted by: majyk
When:2 years, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+ZCW
Channel:#bitbucket
Paste contents:
Raw Source | XML | Display As
# myservice.py

# simple python-dbus service that exposes 1 method called hello()

import gtk
import dbus
import dbus.service
import dbus.glib

class MyDBUSService(dbus.service.Object):
	def __init__(self):
		bus_name = dbus.service.BusName('org.frankhale.helloservice', bus=dbus.SessionBus())

		dbus.service.Object.__init__(self, bus_name, '/org/frankhale/helloservice')

	@dbus.service.method('org.frankhale.helloservice')
	def hello(self):
		return "Hello,World!"

myservice = MyDBUSService()
gtk.main()

#######################

# consumeservice.py

# consumes a method in a service on the dbus

import dbus

bus = dbus.SessionBus()

helloservice = bus.get_object('org.frankhale.helloservice', '/org/frankhale/helloservice')

hello = helloservice.get_dbus_method('hello', 'org.frankhale.helloservice')

print hello()

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.