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

Merge branch 'master' into dev

parents bb16cf7e 6f9caa06
Branches
Tags
No related merge requests found
...@@ -69,9 +69,11 @@ class Account(object): ...@@ -69,9 +69,11 @@ class Account(object):
dead_communities = [] dead_communities = []
for data in json_data['communities']: for data in json_data['communities']:
try: try:
communities.append(Community.load(data)) community = Community.load(data)
communities.append(community)
except NoPeerAvailable: except NoPeerAvailable:
dead_communities.append(data['currency']) community = Community.without_network(data)
dead_communities.append(community)
account = cls(salt, pubkey, name, communities, wallets, account = cls(salt, pubkey, name, communities, wallets,
contacts, dead_communities) contacts, dead_communities)
...@@ -210,7 +212,8 @@ class Account(object): ...@@ -210,7 +212,8 @@ class Account(object):
def jsonify(self): def jsonify(self):
data_communities = [] data_communities = []
for c in self.communities: communities = self.communities + self.dead_communities
for c in communities:
data_communities.append(c.jsonify()) data_communities.append(c.jsonify())
data_wallets = [] data_wallets = []
......
...@@ -32,7 +32,6 @@ class Application(object): ...@@ -32,7 +32,6 @@ class Application(object):
self.load() self.load()
def get_account(self, name): def get_account(self, name):
if not self.accounts[name]:
self.load_account(name) self.load_account(name)
if name in self.accounts.keys(): if name in self.accounts.keys():
return self.accounts[name] return self.accounts[name]
...@@ -63,7 +62,6 @@ class Application(object): ...@@ -63,7 +62,6 @@ class Application(object):
if self.current_account is not None: if self.current_account is not None:
self.save_cache(self.current_account) self.save_cache(self.current_account)
self.current_account = account self.current_account = account
self.load_cache(account)
def load(self): def load(self):
if (os.path.exists(config.parameters['data']) if (os.path.exists(config.parameters['data'])
...@@ -71,7 +69,6 @@ class Application(object): ...@@ -71,7 +69,6 @@ class Application(object):
logging.debug("Loading data...") logging.debug("Loading data...")
with open(config.parameters['data'], 'r') as json_data: with open(config.parameters['data'], 'r') as json_data:
data = json.load(json_data) data = json.load(json_data)
json_data.close()
if 'default_account' in data.keys(): if 'default_account' in data.keys():
self.default_account = data['default_account'] self.default_account = data['default_account']
for account_name in data['local_accounts']: for account_name in data['local_accounts']:
...@@ -83,6 +80,7 @@ class Application(object): ...@@ -83,6 +80,7 @@ class Application(object):
with open(account_path, 'r') as json_data: with open(account_path, 'r') as json_data:
data = json.load(json_data) data = json.load(json_data)
account = Account.load(data) account = Account.load(data)
self.load_cache(account)
self.accounts[account_name] = account self.accounts[account_name] = account
def load_cache(self, account): def load_cache(self, account):
...@@ -90,7 +88,7 @@ class Application(object): ...@@ -90,7 +88,7 @@ class Application(object):
wallet_path = os.path.join(config.parameters['home'], wallet_path = os.path.join(config.parameters['home'],
account.name, '__cache__', wallet.pubkey) account.name, '__cache__', wallet.pubkey)
if os.path.exists(wallet_path): if os.path.exists(wallet_path):
json_data = open(wallet_path, 'r') with open(wallet_path, 'r') as json_data:
data = json.load(json_data) data = json.load(json_data)
wallet.load_caches(data) wallet.load_caches(data)
for community in account.communities: for community in account.communities:
......
...@@ -12,7 +12,7 @@ from ..tools.exceptions import NoPeerAvailable ...@@ -12,7 +12,7 @@ from ..tools.exceptions import NoPeerAvailable
import logging import logging
import inspect import inspect
import hashlib import hashlib
from requests.exceptions import ConnectTimeout from requests.exceptions import RequestException, Timeout
class Cache(): class Cache():
...@@ -59,18 +59,16 @@ class Community(object): ...@@ -59,18 +59,16 @@ class Community(object):
self.peers = [p for p in peers if p.currency == currency] self.peers = [p for p in peers if p.currency == currency]
self._cache = Cache(self) self._cache = Cache(self)
# After initializing the community from latest peers,
# we refresh its peers tree
logging.debug("Creating community")
self.peers = self.peering()
logging.debug("{0} peers found".format(len(self.peers)))
logging.debug([peer.pubkey for peer in peers])
self._cache.refresh() self._cache.refresh()
@classmethod @classmethod
def create(cls, currency, peer): def create(cls, currency, peer):
return cls(currency, [peer]) community = cls(currency, [peer])
logging.debug("Creating community")
community.peers = community.peering()
logging.debug("{0} peers found".format(len(community.peers)))
logging.debug([peer.pubkey for peer in community.peers])
return community
@classmethod @classmethod
def load(cls, json_data): def load(cls, json_data):
...@@ -92,6 +90,28 @@ class Community(object): ...@@ -92,6 +90,28 @@ class Community(object):
except: except:
pass pass
community = cls(currency, peers)
logging.debug("Creating community")
community.peers = community.peering()
logging.debug("{0} peers found".format(len(community.peers)))
logging.debug([peer.pubkey for peer in community.peers])
return community
@classmethod
def without_network(cls, json_data):
peers = []
currency = json_data['currency']
for data in json_data['peers']:
endpoints = []
for e in data['endpoints']:
endpoints.append(Endpoint.from_inline(e))
peer = Peer(PROTOCOL_VERSION, currency, data['pubkey'],
"0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709",
endpoints, None)
peers.append(peer)
community = cls(currency, peers) community = cls(currency, peers)
return community return community
...@@ -128,14 +148,14 @@ class Community(object): ...@@ -128,14 +148,14 @@ class Community(object):
(next_peer.pubkey not in traversed_pubkeys))) (next_peer.pubkey not in traversed_pubkeys)))
if next_peer.pubkey not in traversed_pubkeys: if next_peer.pubkey not in traversed_pubkeys:
self._peering_traversal(next_peer, found_peers, traversed_pubkeys) self._peering_traversal(next_peer, found_peers, traversed_pubkeys)
except ConnectTimeout: except Timeout:
pass
except TimeoutError:
pass pass
except ConnectionError: except ConnectionError:
pass pass
except ValueError: except ValueError:
pass pass
except RequestException as e:
pass
def peering(self): def peering(self):
peers = [] peers = []
...@@ -210,17 +230,11 @@ class Community(object): ...@@ -210,17 +230,11 @@ class Community(object):
continue continue
else: else:
raise raise
except ConnectTimeout: except Timeout:
# Move the timeout peer to the end
self.peers.remove(peer)
self.peers.append(peer)
continue
except TimeoutError:
# Move the timeout peer to the end # Move the timeout peer to the end
self.peers.remove(peer) self.peers.remove(peer)
self.peers.append(peer) self.peers.append(peer)
continue continue
raise NoPeerAvailable(self.currency, len(self.peers)) raise NoPeerAvailable(self.currency, len(self.peers))
def post(self, request, req_args={}, post_args={}): def post(self, request, req_args={}, post_args={}):
...@@ -233,12 +247,7 @@ class Community(object): ...@@ -233,12 +247,7 @@ class Community(object):
return return
except ValueError as e: except ValueError as e:
raise raise
except ConnectTimeout: except Timeout:
# Move the timeout peer to the end
self.peers.remove(peer)
self.peers.append(peer)
continue
except TimeoutError:
# Move the timeout peer to the end # Move the timeout peer to the end
self.peers.remove(peer) self.peers.remove(peer)
self.peers.append(peer) self.peers.append(peer)
...@@ -261,13 +270,7 @@ class Community(object): ...@@ -261,13 +270,7 @@ class Community(object):
except ValueError as e: except ValueError as e:
value_error = e value_error = e
continue continue
except ConnectTimeout: except Timeout:
tries = tries + 1
# Move the timeout peer to the end
self.peers.remove(peer)
self.peers.append(peer)
continue
except TimeoutError:
tries = tries + 1 tries = tries + 1
# Move the timeout peer to the end # Move the timeout peer to the end
self.peers.remove(peer) self.peers.remove(peer)
......
...@@ -6,9 +6,10 @@ Created on 2 févr. 2014 ...@@ -6,9 +6,10 @@ Created on 2 févr. 2014
import logging import logging
import time import time
import requests
from ucoinpy.api import bma from ucoinpy.api import bma
from PyQt5.QtWidgets import QWidget, QMenu, QAction, QApplication from PyQt5.QtWidgets import QWidget, QMenu, QAction, QApplication, QMessageBox
from PyQt5.QtCore import QModelIndex, Qt, pyqtSlot, QObject, QThread, pyqtSignal from PyQt5.QtCore import QModelIndex, Qt, pyqtSlot, QObject, QThread, pyqtSignal
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from ..gen_resources.currency_tab_uic import Ui_CurrencyTabWidget from ..gen_resources.currency_tab_uic import Ui_CurrencyTabWidget
...@@ -46,8 +47,11 @@ class BlockchainWatcher(QObject): ...@@ -46,8 +47,11 @@ class BlockchainWatcher(QObject):
self.last_block = block_number self.last_block = block_number
except NoPeerAvailable: except NoPeerAvailable:
return return
except requests.exceptions.RequestException as e:
self.connection_error.emit("Cannot check new block : {0}".format(str(e)))
new_block_mined = pyqtSignal(int) new_block_mined = pyqtSignal(int)
connection_error = pyqtSignal(str)
class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
...@@ -72,6 +76,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): ...@@ -72,6 +76,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self.bc_watcher = BlockchainWatcher(self.app.current_account, self.bc_watcher = BlockchainWatcher(self.app.current_account,
community) community)
self.bc_watcher.new_block_mined.connect(self.refresh_block) self.bc_watcher.new_block_mined.connect(self.refresh_block)
self.bc_watcher.connection_error.connect(self.display_error)
self.watcher_thread = QThread() self.watcher_thread = QThread()
self.bc_watcher.moveToThread(self.watcher_thread) self.bc_watcher.moveToThread(self.watcher_thread)
...@@ -100,6 +105,12 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): ...@@ -100,6 +105,12 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self.status_label.setText("Connected : Block {0}" self.status_label.setText("Connected : Block {0}"
.format(block_number)) .format(block_number))
@pyqtSlot(str)
def display_error(self, error):
QMessageBox.critical(self, ":(",
error,
QMessageBox.Ok)
@pyqtSlot(int) @pyqtSlot(int)
def refresh_block(self, block_number): def refresh_block(self, block_number):
if self.list_wallets.model(): if self.list_wallets.model():
......
...@@ -18,6 +18,7 @@ from ..tools.exceptions import NoPeerAvailable ...@@ -18,6 +18,7 @@ from ..tools.exceptions import NoPeerAvailable
from ..__init__ import __version__ from ..__init__ import __version__
import logging import logging
import requests
class Loader(QObject): class Loader(QObject):
...@@ -27,6 +28,7 @@ class Loader(QObject): ...@@ -27,6 +28,7 @@ class Loader(QObject):
self.account_name = "" self.account_name = ""
loaded = pyqtSignal() loaded = pyqtSignal()
connection_error = pyqtSignal(str)
def set_account_name(self, name): def set_account_name(self, name):
self.account_name = name self.account_name = name
...@@ -34,7 +36,12 @@ class Loader(QObject): ...@@ -34,7 +36,12 @@ class Loader(QObject):
@pyqtSlot() @pyqtSlot()
def load(self): def load(self):
if self.account_name != "": if self.account_name != "":
try:
self.app.change_current_account(self.app.get_account(self.account_name)) self.app.change_current_account(self.app.get_account(self.account_name))
except requests.exceptions.RequestException as e:
self.connection_error.emit(str(e))
self.loaded.emit()
self.loaded.emit() self.loaded.emit()
...@@ -69,6 +76,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -69,6 +76,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.loader.moveToThread(self.loader_thread) self.loader.moveToThread(self.loader_thread)
self.loader.loaded.connect(self.loader_finished) self.loader.loaded.connect(self.loader_finished)
self.loader.loaded.connect(self.loader_thread.quit) self.loader.loaded.connect(self.loader_thread.quit)
self.loader.connection_error.connect(self.display_error)
self.loader_thread.started.connect(self.loader.load) self.loader_thread.started.connect(self.loader.load)
self.setWindowTitle("CuteCoin {0}".format(__version__)) self.setWindowTitle("CuteCoin {0}".format(__version__))
self.refresh() self.refresh()
...@@ -83,9 +91,13 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -83,9 +91,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.refresh() self.refresh()
self.busybar.hide() self.busybar.hide()
@pyqtSlot(str)
def display_error(self, error):
QMessageBox.critical(self, ":(",
error,
QMessageBox.Ok)
def action_change_account(self, account_name): def action_change_account(self, account_name):
if self.app.current_account:
self.app.save_cache(self.app.current_account)
self.busybar.show() self.busybar.show()
self.status_label.setText("Loading account {0}".format(account_name)) self.status_label.setText("Loading account {0}".format(account_name))
self.loader.set_account_name(account_name) self.loader.set_account_name(account_name)
...@@ -160,11 +172,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -160,11 +172,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.action_configure_parameters.setEnabled(False) self.action_configure_parameters.setEnabled(False)
self.action_set_as_default.setEnabled(False) self.action_set_as_default.setEnabled(False)
else: else:
for dead in self.app.current_account.dead_communities:
QMessageBox.critical(self, ":(",
"No {0} peers could be joined. Community was lost.".format(dead),
QMessageBox.Ok)
self.action_set_as_default.setEnabled(self.app.current_account.name self.action_set_as_default.setEnabled(self.app.current_account.name
!= self.app.default_account) != self.app.default_account)
self.password_asker = PasswordAskerDialog(self.app.current_account) self.password_asker = PasswordAskerDialog(self.app.current_account)
...@@ -189,6 +196,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -189,6 +196,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
str(e), str(e),
QMessageBox.Ok) QMessageBox.Ok)
continue continue
except requests.exceptions.RequestException as e:
QMessageBox.critical(self, ":(",
str(e),
QMessageBox.Ok)
self.menu_contacts_list.clear() self.menu_contacts_list.clear()
for contact in self.app.current_account.contacts: for contact in self.app.current_account.contacts:
......
...@@ -4,6 +4,7 @@ Created on 6 mars 2014 ...@@ -4,6 +4,7 @@ Created on 6 mars 2014
@author: inso @author: inso
''' '''
import logging import logging
import requests
from ucoinpy.documents.peer import Peer from ucoinpy.documents.peer import Peer
from ucoinpy.key import SigningKey from ucoinpy.key import SigningKey
from ..gen_resources.account_cfg_uic import Ui_AccountConfigurationDialog from ..gen_resources.account_cfg_uic import Ui_AccountConfigurationDialog
...@@ -197,6 +198,10 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog): ...@@ -197,6 +198,10 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog):
QMessageBox.critical(self, "Error", QMessageBox.critical(self, "Error",
str(e), QMessageBox.Ok) str(e), QMessageBox.Ok)
return return
except requests.exceptions.RequestException as e:
QMessageBox.critical(self, "Error",
str(e), QMessageBox.Ok)
return
dialog.accepted.connect(self.action_edit_community) dialog.accepted.connect(self.action_edit_community)
dialog.exec_() dialog.exec_()
......
...@@ -5,6 +5,8 @@ Created on 8 mars 2014 ...@@ -5,6 +5,8 @@ Created on 8 mars 2014
''' '''
import logging import logging
import requests
from ucoinpy.api import bma from ucoinpy.api import bma
from ucoinpy.api.bma import ConnectionHandler from ucoinpy.api.bma import ConnectionHandler
from ucoinpy.documents.peer import Peer from ucoinpy.documents.peer import Peer
...@@ -65,6 +67,11 @@ class StepPageInit(Step): ...@@ -65,6 +67,11 @@ class StepPageInit(Step):
QMessageBox.critical(self.config_dialog, "Server Error", QMessageBox.critical(self.config_dialog, "Server Error",
"Cannot join any peer in this community.") "Cannot join any peer in this community.")
raise raise
except requests.exceptions.RequestException as e:
QMessageBox.critical(self.config_dialog, ":(",
str(e),
QMessageBox.Ok)
raise
def display_page(self): def display_page(self):
self.config_dialog.button_previous.setEnabled(False) self.config_dialog.button_previous.setEnabled(False)
...@@ -87,7 +94,11 @@ class StepPageAddpeers(Step): ...@@ -87,7 +94,11 @@ class StepPageAddpeers(Step):
# We add already known peers to the displayed list # We add already known peers to the displayed list
for peer in self.config_dialog.community.peers: for peer in self.config_dialog.community.peers:
self.config_dialog.peers.append(peer) self.config_dialog.peers.append(peer)
try:
tree_model = PeeringTreeModel(self.config_dialog.community) tree_model = PeeringTreeModel(self.config_dialog.community)
except requests.exceptions.RequestException:
raise
self.config_dialog.tree_peers.setModel(tree_model) self.config_dialog.tree_peers.setModel(tree_model)
self.config_dialog.button_previous.setEnabled(False) self.config_dialog.button_previous.setEnabled(False)
self.config_dialog.button_next.setText("Ok") self.config_dialog.button_next.setText("Ok")
...@@ -129,11 +140,19 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -129,11 +140,19 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
def next(self): def next(self):
if self.step.next_step is not None: if self.step.next_step is not None:
if self.step.is_valid(): if self.step.is_valid():
try:
self.step.process_next() self.step.process_next()
self.step = self.step.next_step self.step = self.step.next_step
next_index = self.stacked_pages.currentIndex() + 1 next_index = self.stacked_pages.currentIndex() + 1
self.stacked_pages.setCurrentIndex(next_index) self.stacked_pages.setCurrentIndex(next_index)
self.step.display_page() self.step.display_page()
except NoPeerAvailable:
return
except requests.exceptions.RequestException as e:
QMessageBox.critical(self.config_dialog, ":(",
str(e),
QMessageBox.Ok)
return
else: else:
self.accept() self.accept()
...@@ -155,8 +174,12 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -155,8 +174,12 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
peer = Peer.from_signed_raw("{0}{1}\n".format(peer_data['raw'], peer = Peer.from_signed_raw("{0}{1}\n".format(peer_data['raw'],
peer_data['signature'])) peer_data['signature']))
if peer.currency == self.community.currency:
self.community.peers.append(peer) self.community.peers.append(peer)
except: else:
QMessageBox.critical(self, "Error",
"This peer doesn't use this community currency.")
except requests.exceptions.RequestException as e:
QMessageBox.critical(self, "Server error", QMessageBox.critical(self, "Server error",
"Cannot get node peering") "Cannot get node peering")
self.tree_peers.setModel(PeeringTreeModel(self.community)) self.tree_peers.setModel(PeeringTreeModel(self.community))
...@@ -187,6 +210,15 @@ Would you like to publish the key ?""".format(self.account.pubkey)) ...@@ -187,6 +210,15 @@ Would you like to publish the key ?""".format(self.account.pubkey))
except ValueError as e: except ValueError as e:
QMessageBox.critical(self, "Pubkey publishing error", QMessageBox.critical(self, "Pubkey publishing error",
e.message) e.message)
except NoPeerAvailable as e:
QMessageBox.critical(self, "Network error",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
else: else:
return return
......
...@@ -241,9 +241,13 @@ class Node(QGraphicsEllipseItem): ...@@ -241,9 +241,13 @@ class Node(QGraphicsEllipseItem):
def contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent): def contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent):
""" """
Right click on node to show node menu Right click on node to show node menu
Except on wallet node
:param event: scene context menu event :param event: scene context menu event
""" """
# no menu on the wallet node
if self.status_wallet:
return None
# create node context menus # create node context menus
self.menu = QMenu() self.menu = QMenu()
# action add identity as contact # action add identity as contact
......
...@@ -28,8 +28,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -28,8 +28,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
self.setupUi(self) self.setupUi(self)
# add combobox events # add combobox events
self.comboBoxSearch.lineEdit().textEdited.connect(self.search) self.comboBoxSearch.lineEdit().returnPressed.connect(self.search)
self.comboBoxSearch.lineEdit().returnPressed.connect(self.combobox_return_pressed)
# add scene events # add scene events
self.graphicsView.scene().node_clicked.connect(self.draw_graph) self.graphicsView.scene().node_clicked.connect(self.draw_graph)
...@@ -54,14 +53,35 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -54,14 +53,35 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
:param public_key: Public key of the identity :param public_key: Public key of the identity
""" """
# reset graph
graph = dict()
try: try:
certifiers = self.community.request(bma.wot.CertifiersOf, {'search': public_key}) certifiers = self.community.request(bma.wot.CertifiersOf, {'search': public_key})
except ValueError as e:
logging.debug('bma.wot.CertifiersOf request error : ' + str(e))
try:
results = self.community.request(bma.wot.Lookup, {'search': public_key})
except ValueError as e: except ValueError as e:
logging.debug('bma.wot.CertifiersOf request error : ' + str(e)) logging.debug('bma.wot.CertifiersOf request error : ' + str(e))
return False return False
# reset graph # show only node of this non member (to certify him)
graph = dict() node_status = 0
if public_key == self.account.pubkey:
node_status += NODE_STATUS_HIGHLIGHTED
node_status += NODE_STATUS_OUT
node_status += NODE_STATUS_SELECTED
# selected node
graph[public_key] = {'id': public_key, 'arcs': list(), 'text': results['results'][0]['uids'][0]['uid'], 'tooltip': public_key, 'status': node_status}
# draw graph in qt scene
self.graphicsView.scene().update_wot(graph)
return False
except Exception as e:
logging.debug('bma.wot.CertifiersOf request error : ' + str(e))
return False
# add wallet node # add wallet node
node_status = 0 node_status = 0
...@@ -173,23 +193,22 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -173,23 +193,22 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
self.account.pubkey self.account.pubkey
) )
def combobox_return_pressed(self): def search(self):
""" """
Search nodes when return is pressed in combobox lineEdit Search nodes when return is pressed in combobox lineEdit
""" """
self.search(self.comboBoxSearch.lineEdit().text()) text = self.comboBoxSearch.lineEdit().text()
def search(self, text):
"""
Search nodes when text is edited in combobox lineEdit
"""
if len(text) < 2: if len(text) < 2:
return False return False
try:
response = self.community.request(bma.wot.Lookup, {'search': text}) response = self.community.request(bma.wot.Lookup, {'search': text})
except Exception as e:
logging.debug('bma.wot.Lookup request error : ' + str(e))
return False
nodes = {} nodes = {}
for identity in response['results']: for identity in response['results']:
if identity['uids'][0]['others']:
nodes[identity['pubkey']] = identity['uids'][0]['uid'] nodes[identity['pubkey']] = identity['uids'][0]['uid']
if nodes: if nodes:
...@@ -201,6 +220,11 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -201,6 +220,11 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
self.comboBoxSearch.addItem(uid) self.comboBoxSearch.addItem(uid)
self.comboBoxSearch.showPopup() self.comboBoxSearch.showPopup()
if len(nodes) == 1:
self.draw_graph(
list(nodes.keys())[0]
)
def select_node(self, index): def select_node(self, index):
""" """
Select node in graph when item is selected in combobox Select node in graph when item is selected in combobox
...@@ -215,6 +239,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ...@@ -215,6 +239,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
def sign_node(self, metadata): def sign_node(self, metadata):
# open certify dialog # open certify dialog
dialog = CertificationDialog(self.account, self.password_asker) dialog = CertificationDialog(self.account, self.password_asker)
dialog.combo_community.setCurrentText(self.community.name())
dialog.edit_pubkey.setText(metadata['id']) dialog.edit_pubkey.setText(metadata['id'])
dialog.radio_pubkey.setChecked(True) dialog.radio_pubkey.setChecked(True)
dialog.combo_community.setCurrentText(self.community.name()) dialog.combo_community.setCurrentText(self.community.name())
......
...@@ -8,7 +8,7 @@ from ucoinpy.api import bma ...@@ -8,7 +8,7 @@ from ucoinpy.api import bma
from ucoinpy.documents.peer import BMAEndpoint, Peer from ucoinpy.documents.peer import BMAEndpoint, Peer
from PyQt5.QtCore import QAbstractItemModel, QModelIndex, Qt from PyQt5.QtCore import QAbstractItemModel, QModelIndex, Qt
from .peer import PeerItem, RootItem from .peer import PeerItem, RootItem
from requests.exceptions import ConnectTimeout from requests.exceptions import Timeout
import logging import logging
...@@ -111,9 +111,7 @@ class PeeringTreeModel(QAbstractItemModel): ...@@ -111,9 +111,7 @@ class PeeringTreeModel(QAbstractItemModel):
peer_data['value']['signature'])) peer_data['value']['signature']))
child_node_item = PeerItem(peer, peer_item) child_node_item = PeerItem(peer, peer_item)
peer_item.appendChild(child_node_item) peer_item.appendChild(child_node_item)
except ConnectTimeout: except Timeout:
continue
except TimeoutError:
continue continue
except StopIteration as e: except StopIteration as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment