communicator db responses probably finished

This commit is contained in:
Kevin Froman 2019-01-07 15:09:58 -06:00
parent aeb9a6e775
commit c5a0b29988
5 changed files with 18 additions and 10 deletions

View File

@ -296,10 +296,13 @@ class API:
@app.route('/queueResponse/<name>') @app.route('/queueResponse/<name>')
def queueResponse(name): def queueResponse(name):
try:
res = self.queueResponse[name]
except KeyError:
resp = '' resp = ''
try:
resp = self.queueResponse[name]
except KeyError:
pass
else:
del self.queueResponse[name]
return Response(resp) return Response(resp)
@app.route('/ping') @app.route('/ping')

View File

@ -507,9 +507,10 @@ class OnionrCommunicatorDaemon:
else: else:
logger.info('Recieved daemonQueue command:' + cmd[0]) logger.info('Recieved daemonQueue command:' + cmd[0])
if cmd[4] != '': if cmd[4] != '' and cmd[0] not in ('', None):
if response != '': if response != '':
self._core._utils.localCommand('queueResponseAdd', data='/' + cmd[4], post=True, postData=response) self._core._utils.localCommand('queueResponseAdd/' + cmd[4], post=True, postData={'data': response})
response = ''
self.decrementThreadCount('daemonCommands') self.decrementThreadCount('daemonCommands')

View File

@ -384,7 +384,8 @@ class Core:
Get a response sent by communicator to the API, by requesting to the API Get a response sent by communicator to the API, by requesting to the API
''' '''
assert len(responseID) > 0 assert len(responseID) > 0
resp = self._utils.localCommand('queueResponse', data='/' + responseID, post=True) resp = self._utils.localCommand('queueResponse/' + responseID)
return resp
def clearDaemonQueue(self): def clearDaemonQueue(self):
''' '''

View File

@ -397,8 +397,12 @@ class Onionr:
randID = str(uuid.uuid4()) randID = str(uuid.uuid4())
self.onionrCore.daemonQueueAdd('connectedPeers', responseID=randID) self.onionrCore.daemonQueueAdd('connectedPeers', responseID=randID)
while True: while True:
time.sleep(1) try:
time.sleep(3)
peers = self.onionrCore.daemonQueueGetResponse(randID) peers = self.onionrCore.daemonQueueGetResponse(randID)
except KeyboardInterrupt:
break
if not type(peers) is None:
if peers not in ('', None): if peers not in ('', None):
print(peers) print(peers)
break break

View File

@ -173,7 +173,6 @@ class OnionrUtils:
if data != '': if data != '':
data = '&data=' + urllib.parse.quote_plus(data) data = '&data=' + urllib.parse.quote_plus(data)
payload = 'http://%s:%s/%s%s' % (hostname, config.get('client.client.port'), command, data) payload = 'http://%s:%s/%s%s' % (hostname, config.get('client.client.port'), command, data)
try: try:
if post: if post:
retData = requests.post(payload, data=postData, headers={'token': config.get('client.webpassword')}).text retData = requests.post(payload, data=postData, headers={'token': config.get('client.webpassword')}).text