Skip to content
Snippets Groups Projects
Commit a89b532e authored by inso's avatar inso
Browse files

Fix errors due to bad connection quality

parent a936dec2
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ from ucoinpy.api import bma as bma
from ucoinpy.api.bma import ConnectionHandler
import asyncio
from aiohttp.errors import ClientError
from aiohttp.errors import ClientError, DisconnectedError
import logging
import time
import jsonschema
......@@ -21,7 +21,7 @@ from PyQt5.QtCore import QObject, pyqtSignal
class Node(QObject):
"""
A node is a peer seend from the client point of view.
A node is a peer send from the client point of view.
This node can have multiple states :
- ONLINE : The node is available for requests
- OFFLINE: The node is disconnected
......@@ -317,6 +317,9 @@ class Node(QObject):
except ClientError:
logging.debug("Client error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
......@@ -338,6 +341,9 @@ class Node(QObject):
except ClientError:
logging.debug("Client error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
......@@ -375,6 +381,9 @@ class Node(QObject):
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey))
self.state = Node.CORRUPTED
......@@ -405,6 +414,9 @@ class Node(QObject):
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey))
self.state = Node.CORRUPTED
......@@ -443,6 +455,9 @@ class Node(QObject):
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey))
self.state = Node.CORRUPTED
......@@ -480,6 +495,9 @@ class Node(QObject):
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey))
self.state = Node.CORRUPTED
......@@ -494,6 +512,9 @@ class Node(QObject):
except asyncio.TimeoutError:
logging.debug("Timeout error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except DisconnectedError:
logging.debug("Disconnected error : {0}".format(self.pubkey))
self.state = Node.OFFLINE
except jsonschema.ValidationError:
logging.debug("Validation error : {0}".format(self.pubkey))
self.state = Node.CORRUPTED
......
......@@ -6,6 +6,7 @@ Created on 8 mars 2014
import logging
import asyncio
import aiohttp
from PyQt5.QtWidgets import QDialog, QMenu, QMessageBox, QApplication
from PyQt5.QtGui import QCursor
......@@ -88,8 +89,8 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
try:
self.node = yield from Node.from_address(None, server, port)
if self.node:
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
......@@ -119,8 +120,10 @@ Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
else:
self.config_dialog.label_error.setText(self.tr("Your account already exists on the network"))
else:
self.config_dialog.label_error.setText(self.tr("Could not connect."))
except aiohttp.errors.DisconnectedError as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
@pyqtSlot()
def check_register(self):
......
......@@ -41,7 +41,8 @@ def async_exception_handler(loop, context):
log_lines.append('{}: {!r}'.format(key, context[key]))
logging.error('\n'.join(log_lines), exc_info=exc_info)
if "Unclosed" not in message:
if "Unclosed" not in message and \
"gaierror(-2" not in message:
os._exit(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment