I am trying to call methods from the klipper bus using python. But I could not do it. Here is what I am trying:
>>> import dbus
>>> bus = dbus.SessionBus()
>>> proxy = bus.get_object("org.kde.klipper","/org/kde/klipper")
>>> print proxy
<ProxyObject wrapping <dbus._dbus.SessionBus (session) at 0x7fc249da3bf0> :1.67 /org/kde/klipper at 0x7fc249dc16d0>
>>> iface = dbus.Interface(proxy,"org.kde.klipper.klipper")
>>> print iface
<Interface <ProxyObject wrapping <dbus._dbus.SessionBus (session) at 0x7fc249da3bf0> :1.67 /org/kde/klipper at 0x7fc249dc16d0> implementing 'org.kde.klipper.klipper' at 0x7fc249dc1790>
>>> print iface.getClipboardContents()
ERROR:dbus.proxies:Introspect error on :1.67:/org/kde/klipper: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/kde/klipper'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 68, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 140, in __call__
**keywords)
File "/usr/lib/python2.6/site-packages/dbus/connection.py", line 622, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/kde/klipper'
As you can see, it sets up both the proxy and the interface. But I can not call methods through this interface.
What can I do? What am I doing wrong?
Editing:
Well, when I look at "qdbusviewer", I saw the exact path klipper. Therefore change
>> proxy = bus.get_object("org.kde.klipper","/org/kde/klipper")
this line with this:
>>> proxy = bus.get_object("org.kde.klipper","/klipper")
Solves the problem.
I hope this post helps someone
source
share