[PyQt] QtDBus: Calling a method with an Array of Strings signature with Python 3

Chris Mayo cjmayo at users.sourceforge.net
Tue Dec 6 17:43:36 GMT 2011


On 05/12/11 21:31, Phil Thompson wrote:
> On Mon, 05 Dec 2011 19:12:33 +0000, Chris Mayo
> <cjmayo at users.sourceforge.net>  wrote:
>>>
>>> Try this...
>>>
>>> arg = QDBusArgument()
>>> arg.beginArray(QMetaType.QString)
>>> arg.add("")
>>> arg.endArray()
>>>
>>> ....and pass arg to call().
>>
>> Doesn't seem to work:
>>
>> device_iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
>> 	'/org/freedesktop/UDisks/devices/sr0', 'org.freedesktop.UDisks.Device',
>
>> bus)
>>
>> arg = QtDBus.QDBusArgument()
>> arg.beginArray(QMetaType.QString)
>> arg.add("")
>> arg.endArray()
>>
>> reply = device_iface.call("DriveEject", arg)
>> print(reply.errorMessage())
>>
>>
>> Returns:
>>
>> Unknown option
>
> ....because "" is not a valid option? According to...
>
> http://hal.freedesktop.org/docs/udisks/Device.html#Device.DriveEject
>
> ...."unmount" is the only valid option.
>
> Phil

Indeed it does work as:

arg = QtDBus.QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add("unmount")
arg.endArray()


and so does:

arg = QtDBus.QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.endArray()

Experimenting with other calls shows this is the way to create an empty 
Array of Strings.

Chris


More information about the PyQt mailing list