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>')
def queueResponse(name):
resp = ''
try:
res = self.queueResponse[name]
resp = self.queueResponse[name]
except KeyError:
resp = ''
pass
else:
del self.queueResponse[name]
return Response(resp)
@app.route('/ping')

View File

@ -507,9 +507,10 @@ class OnionrCommunicatorDaemon:
else:
logger.info('Recieved daemonQueue command:' + cmd[0])
if cmd[4] != '':
if cmd[4] != '' and cmd[0] not in ('', None):
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')

View File

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

View File

@ -397,11 +397,15 @@ class Onionr:
randID = str(uuid.uuid4())
self.onionrCore.daemonQueueAdd('connectedPeers', responseID=randID)
while True:
time.sleep(1)
peers = self.onionrCore.daemonQueueGetResponse(randID)
if peers not in ('', None):
print(peers)
try:
time.sleep(3)
peers = self.onionrCore.daemonQueueGetResponse(randID)
except KeyboardInterrupt:
break
if not type(peers) is None:
if peers not in ('', None):
print(peers)
break
def listPeers(self):
logger.info('Peer transport address list:')

View File

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