[PyQt] QtDBus: Unable to convert Array of Object Paths
Chris Mayo
cjmayo at users.sourceforge.net
Thu Dec 1 20:20:34 GMT 2011
On 30/11/11 16:37, Phil Thompson wrote:
> On Sun, 27 Nov 2011 12:58:27 +0000, Chris Mayo
> <cjmayo at users.sourceforge.net> wrote:
>> On 27/11/11 12:51, Phil Thompson wrote:
>>> On Sun, 27 Nov 2011 12:47:09 +0000, Chris Mayo
>>> <cjmayo at users.sourceforge.net> wrote:
>>>> With PyQt-x11-gpl-snapshot-4.9-e8284ed41e49,
>>>> sip-4.13.1-snapshot-3b44dc2f0efd and:
>>>>
>>>> bus = QtDBus.QDBusConnection.systemBus()
>>>> iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
>>>> '/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)
>>>>
>>>> print(iface.call('EnumerateDeviceFiles').arguments())
>>>> print(iface.call('EnumerateDevices').arguments())
>>>>
>>>>
>>>> the end of the output is:
>>>>
>>>> 0000:00:1f.2-scsi-5:0:0:0-part2', '/dev/fd0']]
>>>> Traceback (most recent call last):
>>>> File "./objectpath.py", line 10, in<module>
>>>> print(iface.call('EnumerateDevices').arguments())
>>>> TypeError: unable to convert a C++ 'QDBusArgument' instance to a
> Python
>>>> object
>>>>
>>>>
>>>> EnumerateDeviceFiles returns an Array of Strings, but EnumerateDevices
>>>> returns an Array of Object Paths
>>>>
>>>
> http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.EnumerateDevices
>>>>
>>>> Python 3.2.2, Qt 4.7.4, udisks 1.0.4, dbus 1.4.16 on amd64 Linux
>>>
>>> Can you send me a complete test case?
>>>
>>> Thanks,
>>> Phil
>>
>> That was it! Nearly anyway, in full:
>>
>> #!/usr/bin/python
>>
>> from PyQt4 import QtDBus
>>
>> bus = QtDBus.QDBusConnection.systemBus()
>> iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
>> '/org/freedesktop/UDisks', 'org.freedesktop.UDisks', bus)
>>
>> print(iface.call('EnumerateDeviceFiles').arguments())
>> print(iface.call('EnumerateDevices').arguments())
>
> Tonight's snapshot will fix this. However there needs to be some
> discussion about the best way to (de)marshall arguments.
Can't get ee8b9c7eb565 to compile:
Generating the C++ source for the QtDBus module...
sip:
/var/tmp/portage/dev-python/PyQt4-4.9_pre20111201/work/PyQt-x11-gpl-snapshot-4.9-ee8b9c7eb565-2.7/sip/QtDBus/qdbusextratypes.sip:95:
A class, exception, namespace or mapped type has already been defined
with the same name
Error: Unable to create the C++ code.
>
> I propose that marshalling of composite types uses QDBusArgument (as you
> do in C++). However I propose that demarshalling is done automatically,
> because...
>
> 1. It is Pythonic.
> 2. The QDBusArgument API will need changing in Python if it is to support
> both marshalling and demarshalling.
>
> There remains a question of how far to demarshall automatically. At the
> moment your example will return a Python list of QDBusObjectPath instances.
> As QDBusObjectPath is just a thin wrapper around QString should this be
> removed and just the string returned? The same would apply to
> QDBusSignature and QDBusVariant. Is it important to be able to distinguish
> between a return value that is a simple string and one that is an object
> path?
I'm no dbus expert but certainly I would use the QDBusObjectPath
instances just as plain strings. Looks like the only advantage is when
creating QDBusObjectPath it will do some checking for you.
> As far as marshalling with QDBusArgument is concerned, I'm inclined to
> ignore the shift operators and to implement explicit writeInt32(),
> writeUInt32() etc methods - as happens with QDataStream.
Bit beyond me. N.B. if you're not following it there has been some
activity on
https://bugs.freedesktop.org/show_bug.cgi?id=26420
still a bit of a long shot in terms of dbus-python being resurrected for
Python 3 maybe but some discussion on types.
> Thoughts?
>
> Phil
More information about the PyQt
mailing list