Search code examples
pythondictionarydbus

D-Bus D-Feet Send Dictionary of String,Variants in Python Syntax


I'm trying to use D-Feet to send D-Bus commands for ConnMan. D-Feet says all Parameters should be in "Python Syntax".

The D-Bus method is described by D-Bus as this:

ConnectProvider(Dict of {String,Variant} provider) => (Object Path path)

I've tried each of these ( Python dictionaries ):

{u'Type': u'wifi', u'Mode': u'managed', u'SSID': u'testSSID', u'Security': u'WPA', u'Passphrase': u'test'}
{'Type': 'wifi', 'Mode': 'managed', 'SSID': 'testSSID', 'Security': 'WPA', 'Passphrase': 'test'}
{"Type": "wifi", "Mode": "managed", "SSID": "testSSID", "Security": "WPA", "Passphrase": "test"}
{"Type":__import__('dbus').String("wifi", variant_level=1),"Mode":__import__('dbus').String("managed", variant_level=1),"SSID":__import__('dbus').String("testSSID", variant_level=1),"Security":__import__('dbus').String("WPA", variant_level=1),"Passphrase":__import__('dbus').String("test", variant_level=1)}

But I keep getting the error 'Invalid Arguments':

enter image description here

I have dbus-monitor --system running so I can view anything happening on the system bus but when I click 'Execute' nothing is actually sent to the bus. I immediately get the error so I am assuming D-Feet is saying the format of the input is incorrect.

What am I doing wrong? How can I send this command? Thanks!


Solution

  • I got this to work in D-Feet as "Method input" to a method that takes an a{sv}:

    {"key": __import__('gi.repository.GLib', globals(), locals(), ['Variant']).Variant("s", "value")}