开发者

How to represent dbus type b(oss) in python?

I'm working on a Mpris V2.1 interface with python开发者_如何学编程.

The interfaces are described in the document: http://www.mpris.org/2.1/spec/Playlists.html#Property:ActivePlaylist

The signature shows it's complex type contains boolean, object and strings. I just wonder how to represent the type in python. Do I have a provider a list or tuple contains each element ? I've tested it but seems not work.


According to D-Bus specification, (b(oss)) is a struct of two elements, first is a boolean, second is a struct of three elements: an object path and two strings. In python this maps to something like:

dbus.Struct((dbus.Boolean(a_boolean),
             dbus.Struct((dbus.ObjectPath(s1),
                          dbus.String(s2),
                          dbus.String(s3)))),
            signature="(b(oss))")

but it can be used as if it was simply a python tuple like:

( a_boolean, (s1, s2, s3) )

Are you writing a client or a server? In the latter case you should also check this question which provides details on exporting properties using python dbus module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜