Ich möchte ein Python-Objekt auf einem Session-Bus veröffentlichen, mit pydbus und Python 2.7. Ich bin neu in pydbus, also bleibe ich beim Beispiel und habe das Tutorial gemacht. Es ist mir jedoch nicht gelungen, einen einfachen Testserver mit pydbus zu starten.pydbus: Wie publiziere ich ein Objekt?
Ich schrieb eine einfache Klasse, mit nur einer Methode, die eine Zeichenfolge zurückgibt. Ich habe eine Schnittstelle angegeben und eine Ereignisschleife erstellt.
Code:
from pydbus import SessionBus
from gi.repository import GObject
loop = GObject.MainLoop()
class Testclass(object):
"""
<node>
<interface name='org.philipp.DBUSTutorial'>
<method name='helloworld'>
<arg type='s' name='reply' direction='out'/>
</method>
</interface>
</node>
"""
def helloworld():
return "Hello World"
bus = SessionBus()
bus.publish("org.philipp.DBUSTutorial", Testclass())
loop.run()
Nach der Ausführung des Skripts ein Fehler wirft.
Fehlermeldung:
Traceback (most recent call last):
File "test.py", line 24, in <module>
bus.publish("org.philipp.DBUSTutorial", Testclass())
File "/usr/local/lib/python2.7/dist-packages/pydbus/publication.py", line 33, in publish
return Publication(self, bus_name, *objects)
File "/usr/local/lib/python2.7/dist-packages/pydbus/publication.py", line 26, in __init__
self._at_exit(bus.register_object(path, object, node_info).__exit__)
File "/usr/local/lib/python2.7/dist-packages/pydbus/registration.py", line 123, in register_object
return ObjectRegistration(self.con, path, interfaces, wrapper, own_wrapper=True)
File "/usr/local/lib/python2.7/dist-packages/pydbus/registration.py", line 103, in __init__
ids = [con.register_object(path, interface, wrapper.call_method, wrapper.get_property, wrapper.set_property) for interface in interfaces]
TypeError: argument vtable: Expected Gio.DBusInterfaceVTable, but got pydbus.registration.instancemethod
Was mache ich falsch? Es wäre toll, wenn jemand mir helfen könnte, meinen Fehler zu finden.