Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/echo-server
diff options
context:
space:
mode:
Diffstat (limited to 'tests/echo-server')
-rwxr-xr-xtests/echo-server55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/echo-server b/tests/echo-server
new file mode 100755
index 0000000..011a8f7
--- /dev/null
+++ b/tests/echo-server
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+import os
+import sys
+import subprocess
+from optparse import OptionParser
+
+import gobject
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+def log(msg, *args):
+ if len(args):
+ print msg % args
+ else:
+ print msg
+
+class EchoServer(dbus.service.Object):
+ """The echo service."""
+ SERVICE_NAME = 'org.laptop.Echo'
+ INTERFACE_NAME = 'org.laptop.Echo'
+
+ def __init__(self, bus_or_name):
+ dbus.service.Object.__init__(self, bus_or_name, '/')
+
+ @dbus.service.method(INTERFACE_NAME,
+ in_signature='s',
+ out_signature='s')
+ def echo(self, msg):
+ return msg
+
+def run():
+ """Start the Rainbow DBus service."""
+ parser = OptionParser(version='0.1')
+ parser.add_option('-f', '--bus-config-file', default='./session-olpc.conf',
+ help='The dbus session bus config file to test.')
+ opts, args = parser.parse_args()
+
+
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SessionBus()
+ name = dbus.service.BusName(EchoServer.SERVICE_NAME, bus)
+ EchoServer(name)
+
+ print 'Echo service running mainloop.'
+ mainloop = gobject.MainLoop()
+ mainloop.run()
+
+def main():
+ run()
+
+if __name__ == '__main__':
+ main()