diff options
author | Sascha Silbe <sascha-pgp@silbe.org> | 2010-07-21 17:30:43 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha-pgp@silbe.org> | 2010-07-21 17:30:43 (GMT) |
commit | 5ab8ddb8ddb8dc6925cb3bb5f52e0a06b7a1c439 (patch) | |
tree | 01e6ca6d9d6eaa54052480200f039c8e50f0166f /tests/echo-server | |
parent | d4fe57f377d8f78f02a9e5f6d9c201b4e9eb86f4 (diff) |
rearrange source tree to match that of the tarball
Diffstat (limited to 'tests/echo-server')
-rwxr-xr-x | tests/echo-server | 55 |
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() |