Skip to content

Commit

Permalink
Fix crash #357
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Jan 30, 2016
1 parent b86bc2c commit 15f5178
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
19 changes: 10 additions & 9 deletions src/sakia/core/net/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
"""

from ucoinpy.documents.peer import Peer, Endpoint, BMAEndpoint
from ucoinpy.documents import Block, BlockId
from ucoinpy.documents import Block, BlockId, MalformedDocumentError
from ...tools.exceptions import InvalidNodeCurrency
from ...tools.decorators import asyncify
from ucoinpy.api import bma as bma
from ucoinpy.api.bma import ConnectionHandler

import json
from aiohttp.errors import ClientError, DisconnectedError, TimeoutError, \
WSClientDisconnectedError, WSServerHandshakeError, ClientResponseError
from aiohttp.errors import WSClientDisconnectedError, WSServerHandshakeError, ClientResponseError
from aiohttp.errors import ClientError, DisconnectedError
from asyncio import TimeoutError
import logging
Expand Down Expand Up @@ -588,11 +586,14 @@ async def request_peers(self):

def refresh_peer_data(self, peer_data):
if "raw" in peer_data:
str_doc = "{0}{1}\n".format(peer_data['raw'],
peer_data['signature'])
peer_doc = Peer.from_signed_raw(str_doc)
pubkey = peer_data['pubkey']
self.neighbour_found.emit(peer_doc, pubkey)
try:
str_doc = "{0}{1}\n".format(peer_data['raw'],
peer_data['signature'])
peer_doc = Peer.from_signed_raw(str_doc)
pubkey = peer_data['pubkey']
self.neighbour_found.emit(peer_doc, pubkey)
except MalformedDocumentError as e:
logging.debug(str(e))
else:
logging.debug("Incorrect leaf reply")

Expand Down
11 changes: 6 additions & 5 deletions src/sakia/gui/process_cfg_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import asyncio
import aiohttp

from PyQt5.QtWidgets import QDialog, QMenu, QMessageBox, QApplication
from ucoinpy.documents import MalformedDocumentError
from PyQt5.QtWidgets import QDialog, QMenu, QApplication
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
from PyQt5.QtCore import pyqtSignal, QObject

from ..gen_resources.community_cfg_uic import Ui_CommunityConfigurationDialog
from ..models.peering import PeeringTreeModel
Expand Down Expand Up @@ -73,7 +74,7 @@ async def check_guest(self, checked=False):
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except ValueError as e:
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))

@asyncify
Expand Down Expand Up @@ -101,7 +102,7 @@ async def check_connect(self, checked=False):
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except ValueError as e:
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))

@asyncify
Expand Down Expand Up @@ -144,7 +145,7 @@ async def check_register(self, checked=False):
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except ValueError as e:
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))

def is_valid(self):
Expand Down

0 comments on commit 15f5178

Please sign in to comment.