Свойства набора объектов DBus Rhythmbox

у меня проблемы с Gobject Introspection в Python. Я пытаюсь получить доступ к Rhythmbox через DBUS, и я могу получить доступ к методам внутри org.mpris.MediaPlayer2.Player, но я пытаюсь установить значения для атрибутов org.mpris.MediaPlayer2.Player, что у меня не работает.

from gi.repository import Gio
connection = Gio.bus_get_sync(Gio.BusType.SESSION, None)
player = Gio.DBusProxy.new_sync(connection, 0, None, 'org.gnome.Rhythmbox3', '/org/mpris/MediaPlayer2', 'org.mpris.MediaPlayer2.Player', None)

properties = Gio.DBusProxy.new_sync(connection, 0, None, 'org.gnome.Rhythmbox3', '/org/mpris/MediaPlayer2', 'org.freedesktop.DBus.Properties', None)

Я могу использовать такие методы, как player.PlayPause(). когда я пытаюсь

       properties.Set('org.mpris.MediaPlayer2.Player.rhythmbox', 'Volume', data)

Я получаю сообщение об ошибке:

Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 69, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 626, in _doReadOrWrite
    why = selectable.doRead()
--- <exception caught here> ---
  File "/usr/lib/python2.7/site-packages/twisted/internet/udp.py", line 147, in doRead
    self.protocol.datagramReceived(data, addr)
  File "RhythmboxDbus.py", line 27, in datagramReceived
    properties.Set('org.mpris.MediaPlayer2.Player.rhythmbox', 'Volume', data)
  File "/usr/lib/python2.7/site-packages/gi/overrides/Gio.py", line 156, in __call__
    arg_variant = GLib.Variant(signature, tuple(args))
  File "/usr/lib/python2.7/site-packages/gi/overrides/GLib.py", line 185, in __new__
    (v, rest_format, _) = creator._create(format_string, [value])
  File "/usr/lib/python2.7/site-packages/gi/overrides/GLib.py", line 68, in _create
    v = constructor(args[0])
  File "/usr/lib/python2.7/site-packages/gi/types.py", line 76, in constructor
    return info.invoke(cls, *args, **kwargs)
exceptions.TypeError: Must be string, not tuple

person Small Zane    schedule 13.11.2012    source источник
comment
Данные — это строка, содержащая числа от 0 до 100.   -  person Small Zane    schedule 14.11.2012
comment
Вопрос MPRIS + Python (dbus): свойства чтения и записи похож на вашу проблему и имеет решение с использованием пакета dbus. Это может быть полезно тем, что вы сможете перенести решение в решение на основе gi.   -  person Pedro Romano    schedule 14.11.2012
comment
@Small Zane - Похоже, вы используете DBus из приложения Twisted. Существует альтернатива python-dbus для Twisted, которую вы, возможно, захотите рассмотреть: pypi.python.org/ pypi/txdbus/1.0   -  person Rakis    schedule 16.11.2012