summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2010-05-27 15:56:44 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2010-06-03 17:08:09 +0200
commitefff43effc0fd2f7bbdaf25785a15da32a415753 (patch)
treec6d1482d66a8eb37c9b5dc8d074ffd0fee2676f3
parent3c5b0fbe19a47f2c74e139291dd39f8ec81fa0c8 (diff)
downloadjson-dbus-bridge-efff43effc0fd2f7bbdaf25785a15da32a415753.tar.gz
json-dbus-bridge-efff43effc0fd2f7bbdaf25785a15da32a415753.tar.xz
[demo] add python dbus service
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--demo/Makefile.am3
-rwxr-xr-xdemo/dbus-python-service.py46
2 files changed, 49 insertions, 0 deletions
diff --git a/demo/Makefile.am b/demo/Makefile.am
index 9c3188b..d5c46ab 100644
--- a/demo/Makefile.am
+++ b/demo/Makefile.am
@@ -5,3 +5,6 @@ SUBDIRS = \
MAINTAINERCLEANFILES = \
Makefile.in
+EXTRA_DIST = \
+ dbus-python-service.py
+
diff --git a/demo/dbus-python-service.py b/demo/dbus-python-service.py
new file mode 100755
index 0000000..3abedc1
--- /dev/null
+++ b/demo/dbus-python-service.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python2.5
+#
+# json dbus bridge
+#
+# Copyright (c) 2009 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import gobject
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+class Service(dbus.service.Object):
+ def __init__(self, bus, name):
+ self._state = 1
+ dbus.service.Object.__init__(self, None, "/", name)
+
+ @dbus.service.method("com.pengutronix.devel.Data",
+ in_signature='', out_signature='a{sai}')
+ def Dump(self):
+ return {"foo": [1, 2], "bar": [3, 4] }
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ session_bus = dbus.SessionBus()
+ name = dbus.service.BusName("com.pengutronix.devel.demo1", session_bus)
+ object = Service(session_bus, name)
+
+ mainloop = gobject.MainLoop()
+ mainloop.run()
+