(i know this resembles Python and d-bus: How to set up main loop? , but without complete code in the "Answer", i'm unable to figure out where i'm going wrong. it might just be a change in a Skype)
Here is my program:
import gobject
import dbus
import dbus.mainloop.glib
dbus_gmainloop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
sessbus = dbus.SessionBus()
skype = sessbus.get_object('com.Skype.API', '/com/Skype')
skypec = sessbus.get_object('com.Skype.API', '/com/Skype/Client')
skype_iface = dbus.Interface(skype, dbus_interface='com.Skype.API')
skype_iface.Invoke("NAME py1")
# ... waits for user click in Skype ...
#==> dbus.String(u'OK')
skype_iface.Invoke("PROTOCOL 7")
#==> dbus.String(u'PROTOCOL 7')
def got_signal(sender, destination, member, interface, path):
print "got_signal(sender=%s, dest=%s, member=%s, iface=%s, path=%s)" \
% (sender, destination, member, interface, path)
skypec.connect_to_signal('Notify', got_signal, sender_keyword='sender', \
destination_keyword='destination', member_keyword='member', \
interface_keyword='interface', path_keyword='path')
mainloop = gobject.MainLoop()
mainloop.run()
When run (e.g. python skype-call.py
), it pauses after sending the NAME py1
command to Skype and waits for an interactive confirmation in the Skype UI, then continues. As such, the skype_iface
object is clearly working at least to a certain degree.
However, python then emits the following error:
ERROR:dbus.proxies:Introspect error on :1.152:/com/Skype/Client: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: No such object path '/com/Skype/Client'
I also tried the following (instead of connect_to_signal
, just before starting the gobject mainloop at the end):
def receiver(x, **kwargs):
print "receiver(%s)" % (x,)
sessbus.add_signal_receiver(receiver, signal_name='Notify', \
dbus_interface='com.Skype.API', bus_name='com.Skype.API', path='/com/Skype/Client')
And while that didn't complain, it never gets called. I tried sending the Skype user a message. What sorts of events should trigger it?
The docs at https://dev.skype.com/desktop-api-reference#DBUSUsage aren't terribly helpful.
This is Skype for Linux 4.2.0.11 on Debian 7.0 multiarch (amd64/i386).