Skip to content Skip to sidebar Skip to footer

How To Pass An Array Of String To Dbus In Pyqt5?

I'm trying to make a dbus call using python3.4 and pyqt5.4 to a java-written daemon, the signature of the daemon for the method I'm calling is asa{sv} The call I'm doing is fpiudae

Solution 1:

According to the dbus-spec, the string-type is defined as follows:

STRING 115 (ASCII 's') UTF-8 string (must be valid UTF-8). Must be nul terminated and contain no other nul bytes.

Which seems to imply that you should pass a UTF-8 encoded bytes object, rather than a unicode object.

EDIT:

You might need to pass this as a QByteArray:

QtCore.QByteArray(unicode_string.encode('utf-8'))

Solution 2:

5 years later, an answer appears!

You can specify the type signature of a dbus argument with QDbusArgument. Here's an example:

filepath = QDBusArgument()
filepath.add(['/home/svalo/programmi/devel/pythondeps'], QMetaType.QStringList)
result = fpiudaemon.call('sign',filepath,options)

Obviously make sure that your data can be converted directly into the type you specified.

Post a Comment for "How To Pass An Array Of String To Dbus In Pyqt5?"