dbus/python/examples/example-service.py
Robert McQueen 6fbd1c7ff5 2005-10-29 Robert McQueen <robot101@debian.org>
* python/dbus_bindings.pyx: Tweak 'raise AssertionError' to assert().
        Add checking for the end of struct character when marshalling a
        struct in MessageIter.append_strict.

        * python/examples/example-service.py,
        python/examples/gconf-proxy-service.py,
        python/examples/gconf-proxy-service2.py: Update to use gobject
        mainloop directly rather than appearing to depend on gtk.

        * python/test/test-client.py, python/test/test-server.py: Remove
        obsolete and broken test scripts for old bindings. We have up to date
        and working tests in test/python/.
2005-10-29 22:04:01 +00:00

30 lines
920 B
Python

#!/usr/bin/env python
import dbus
import dbus.service
import dbus.glib
import gobject
class SomeObject(dbus.service.Object):
def __init__(self, bus_name, object_path="/SomeObject"):
dbus.service.Object.__init__(self, bus_name, object_path)
@dbus.service.method("org.designfu.SampleInterface")
def HelloWorld(self, hello_message):
print (str(hello_message))
return ["Hello", " from example-service.py"]
@dbus.service.method("org.designfu.SampleInterface")
def GetTuple(self):
return ("Hello Tuple", " from example-service.py")
@dbus.service.method("org.designfu.SampleInterface")
def GetDict(self):
return {"first": "Hello Dict", "second": " from example-service.py"}
session_bus = dbus.SessionBus()
name = dbus.service.BusName("org.designfu.SampleService", bus=session_bus)
object = SomeObject(name)
mainloop = gobject.MainLoop()
mainloop.run()