minor changes to previous commit- adding listAddressBook to API

This commit is contained in:
Jonathan Warren 2013-09-03 00:30:48 -04:00
parent cf52d93a67
commit 3ca4578f7f

View File

@ -171,19 +171,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
streamNumber, 'enabled': shared.config.getboolean(addressInKeysFile, 'enabled')}, indent=4, separators=(',', ': ')) streamNumber, 'enabled': shared.config.getboolean(addressInKeysFile, 'enabled')}, indent=4, separators=(',', ': '))
data += ']}' data += ']}'
return data return data
elif method == 'listAddressbook': elif method == 'listAddressBook' or method == 'listAddressbook':
shared.sqlLock.acquire() queryreturn = sqlQuery('''SELECT label, address from addressbook''')
shared.sqlSubmitQueue.put('''SELECT label, address from addressbook''')
shared.sqlSubmitQueue.put('')
queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release()
data = '{"addresses":[' data = '{"addresses":['
for row in queryreturn: for row in queryreturn:
label, address = row label, address = row
label = shared.fixPotentiallyInvalidUTF8Data(label) label = shared.fixPotentiallyInvalidUTF8Data(label)
if len(data) > 20: if len(data) > 20:
data += ',' data += ','
data += json.dumps({'label':label.encode('base64'), 'address': address}) data += json.dumps({'label':label.encode('base64'), 'address': address}, indent=4, separators=(',', ': '))
data += ']}' data += ']}'
return data return data
elif method == 'createRandomAddress': elif method == 'createRandomAddress':