I am on Ubuntu 16.04 and using Python Dbus. I want to return a list of dictionaries over DBus to my client but seem to only be able to return an array of strings. If I changed my dbus signature decorator to 'as{v}', I get an exception: "ValueError: Corrupt type signature". How can I return a list of dictionaries over DBus?
@dbus.service.method("com.example.service.BtScanList", in_signature='', out_signature='as')
def getScanList(self):
btMsg("Starting BT Scan List...")
# Populate device lists ( returns dictionary --> { 'mac_address' : xxx , 'name' : xxx }
self.discoveredDevs = self.getScannedDevices()
returnList = []
for dev in self.discoveredDevs:
returnList.append(dev["name"])
return returnList
EDIT: This also does NOT work:
@dbus.service.method("com.example.service.BtScanList", in_signature='', out_signature='a{sv}')
def getScanList(self):
btMsg("Starting BT Scan List...")
# Populate device lists ( returns dictionary --> { 'mac_address' : xxx , 'name' : xxx }
self.discoveredDevs = self.getScannedDevices()
returnList = dbus.Array()
for dev in self.discoveredDevs:
btMsg(dev)
returnList.append(dbus.Dictionary(dev, signature='sv'))
return returnList
I figured it out, answer is here: