From cbe10f914a3214754d46e21f3bb42f1aad304e82 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 5 Aug 2019 00:25:27 -0500 Subject: [PATCH] progress removing onionr.py --- onionr/apiservers/private/__init__.py | 1 - onionr/apiservers/public/__init__.py | 1 - onionr/communicator/__init__.py | 2 +- onionr/httpapi/fdsafehandler.py | 8 ++++---- onionr/httpapi/miscclientapi/endpoints.py | 1 - onionr/serializeddata.py | 8 ++++++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/onionr/apiservers/private/__init__.py b/onionr/apiservers/private/__init__.py index 7f475163..df32ae88 100644 --- a/onionr/apiservers/private/__init__.py +++ b/onionr/apiservers/private/__init__.py @@ -40,7 +40,6 @@ class PrivateAPI: This initialization defines all of the API entry points and handlers for the endpoints and errors This also saves the used host (random localhost IP address) to the data folder in host.txt ''' - time.sleep(0.3) self.config = config self.serializer = serializeddata.SerializedData() self.startTime = epoch.get_epoch() diff --git a/onionr/apiservers/public/__init__.py b/onionr/apiservers/public/__init__.py index ad301ec8..ee350f85 100644 --- a/onionr/apiservers/public/__init__.py +++ b/onionr/apiservers/public/__init__.py @@ -38,7 +38,6 @@ class PublicAPI: The new client api server, isolated from the public api ''' def __init__(self): - time.sleep(1) app = flask.Flask('PublicAPI') app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024 self.i2pEnabled = config.get('i2p.host', False) diff --git a/onionr/communicator/__init__.py b/onionr/communicator/__init__.py index 72ec8145..40d6106a 100755 --- a/onionr/communicator/__init__.py +++ b/onionr/communicator/__init__.py @@ -144,7 +144,7 @@ class OnionrCommunicatorDaemon: if config.get('general.security_level', 1) == 0 and config.get('general.announce_node', True): # Default to high security level incase config breaks announceTimer = OnionrCommunicatorTimers(self, announcenode.announce_node, 3600, myArgs=[self], requiresPeer=True, maxThreads=1) - announceTimer.count = (announceTimer.frequency - 60) + announceTimer.count = (announceTimer.frequency - 120) else: logger.debug('Will not announce node.') diff --git a/onionr/httpapi/fdsafehandler.py b/onionr/httpapi/fdsafehandler.py index ef45565e..c599efec 100644 --- a/onionr/httpapi/fdsafehandler.py +++ b/onionr/httpapi/fdsafehandler.py @@ -7,13 +7,13 @@ class FDSafeHandler(WSGIHandler): self.timeout.start() try: WSGIHandler.handle(self) - except Exception: - self.handle_error() + except Exception as e: + self.handle_error(e) finally: self.timeout.close() - def handle_error(self): - if v is self.timeout: + def handle_error(self, two, three, four): + if two is self.timeout: self.result = [b"Timeout"] self.start_response("200 OK", []) self.process_result() diff --git a/onionr/httpapi/miscclientapi/endpoints.py b/onionr/httpapi/miscclientapi/endpoints.py index 467ba6e3..64feadea 100644 --- a/onionr/httpapi/miscclientapi/endpoints.py +++ b/onionr/httpapi/miscclientapi/endpoints.py @@ -100,7 +100,6 @@ class PrivateEndpoints: try: return Response(client_api._too_many.get(SerializedData).getStats()) except AttributeError as e: - print("damn", e) pass @private_endpoints_bp.route('/getuptime') diff --git a/onionr/serializeddata.py b/onionr/serializeddata.py index 6ec127f9..b3966bde 100755 --- a/onionr/serializeddata.py +++ b/onionr/serializeddata.py @@ -18,7 +18,7 @@ along with this program. If not, see . ''' -import json +import json, time from coredb import blockmetadb import communicator class SerializedData: @@ -35,7 +35,11 @@ class SerializedData: def getStats(self): '''Return statistics about our node''' stats = {} - comm_inst = self._too_many.get(communicator.OnionrCommunicatorDaemon) + try: + self._too_many + except AttributeError: + time.sleep(1) + comm_inst = self._too_many.get(communicator.OnionrCommunicatorDaemon, args=(self._too_many,)) stats['uptime'] = comm_inst.getUptime() stats['connectedNodes'] = '\n'.join(comm_inst.onlinePeers) stats['blockCount'] = len(blockmetadb.get_block_list())