uint argument in dbus call with python
-
wrote on 23 Oct 2022, 10:37 last edited by l0drex
I want to call a dbus method that has one parameter of type uint. I couldn't figure out how to do that, since my number always gets passed as an integer.
Currently, I am calling it like this:
connection = QDBusConnection.sessionBus() message = QDBusMessage.createMethodCall(...) message.setArguments([0, ...])
That
0
should be of type uint -
I want to call a dbus method that has one parameter of type uint. I couldn't figure out how to do that, since my number always gets passed as an integer.
Currently, I am calling it like this:
connection = QDBusConnection.sessionBus() message = QDBusMessage.createMethodCall(...) message.setArguments([0, ...])
That
0
should be of type uintwrote on 23 Oct 2022, 11:32 last edited by@l0drex
Hi. I do not know anything about DBus. But Python does not have anyuint
type.is anything actually going wrong when you pass that
0
? I would have thought it would be fine, are you sure this is a problem.I see there is a PyPI package for
uint
at https://pypi.org/project/uint/. But I am not sure it is relevant. to your situation. -
@l0drex
Hi. I do not know anything about DBus. But Python does not have anyuint
type.is anything actually going wrong when you pass that
0
? I would have thought it would be fine, are you sure this is a problem.I see there is a PyPI package for
uint
at https://pypi.org/project/uint/. But I am not sure it is relevant. to your situation.wrote on 23 Oct 2022, 13:35 last edited by@JonB I am pretty sure, since I get the following error when calling that dbus function:
ValueError: No such method 'Notify' in interface 'org.freedesktop.Notifications' at object path '/org/freedesktop/Notifications' (signature 'sisssasa{sv}i')
Using QtDbusViewer, I get the following signature:susssasa{sv}i
So as far as I understand, my
0
is being passed as an integer. Since the actual function has a uint as argument, it doesn't find it.I already tried using
ctypes.c_uint(0)
instead, but that didn't work since that is seen as an object. I would like to avoid additional dependencies, since otherwise I could just use the dbus python bindings directly... -
@JonB I am pretty sure, since I get the following error when calling that dbus function:
ValueError: No such method 'Notify' in interface 'org.freedesktop.Notifications' at object path '/org/freedesktop/Notifications' (signature 'sisssasa{sv}i')
Using QtDbusViewer, I get the following signature:susssasa{sv}i
So as far as I understand, my
0
is being passed as an integer. Since the actual function has a uint as argument, it doesn't find it.I already tried using
ctypes.c_uint(0)
instead, but that didn't work since that is seen as an object. I would like to avoid additional dependencies, since otherwise I could just use the dbus python bindings directly...wrote on 23 Oct 2022, 13:44 last edited by@l0drex
Then How to send unsigned values to dBus from Python ?You can use the
DBusArgument
class to do this by specifying theQMetaType
of the argument. -
@l0drex
Then How to send unsigned values to dBus from Python ?You can use the
DBusArgument
class to do this by specifying theQMetaType
of the argument.wrote on 23 Oct 2022, 20:44 last edited by l0drex@JonB
Thanks, but that is for PyQt5. I am using PySide6, and the API there is very different: https://doc.qt.io/qtforpython/PySide6/QtDBus/QDBusArgument.html
I currently can't figure out how to do it there. -
wrote on 29 Oct 2022, 20:12 last edited by
This is currently tracked in PYSIDE-1904 . There is no good solution yet since PySide6 does not expose QVariant.
1/6