summaryrefslogtreecommitdiffstats
path: root/services/python/hello-world.py
blob: 92450ea94a36ee2d5b4b7f5fb082c2525d50ebf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python2.5
#
# json dbus bridge examples
#
# Copyright (c) 2010 by Michael Olbrich <m.olbrich@pengutronix.de>
#
# To the extent possible under law, Pengutronix e.K. has waived all copyright
# and related or neighboring rights to JSON-DBus-Bridge Demo Code.
#


import gobject

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


class Service(dbus.service.Object):
	def __init__(self):
		busname = dbus.service.BusName("com.pengutronix.jdb.Hello", dbus.SessionBus())
		dbus.service.Object.__init__(self, None, "/", busname)


	@dbus.service.method("com.pengutronix.jdb.Hello",
		in_signature='', out_signature='s')
	def HelloWorld(self):
		return "Hello World!"

	@dbus.service.method("com.pengutronix.jdb.Hello",
		in_signature='s', out_signature='s')
	def Echo(self, text):
		return text

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

object = Service()

mainloop = gobject.MainLoop()
mainloop.run()