1
0

trezor: more user friendly when cannot connect

Tell the user and ask if they want to try again.  If they
say no, raise a silent exception.  Apply this more friendly
behaviour to the install wizard too (see issue #1668).
This commit is contained in:
Neil Booth
2016-02-06 19:51:39 +09:00
parent 317e6cea32
commit 16397b1ed7
9 changed files with 51 additions and 44 deletions

View File

@@ -34,6 +34,7 @@ class QtHandlerBase(QObject, PrintError):
logic for handling I/O.'''
qcSig = pyqtSignal(object, object)
ynSig = pyqtSignal(object)
def __init__(self, win, device):
super(QtHandlerBase, self).__init__()
@@ -43,6 +44,7 @@ class QtHandlerBase(QObject, PrintError):
win.connect(win, SIGNAL('passphrase_dialog'), self.passphrase_dialog)
win.connect(win, SIGNAL('word_dialog'), self.word_dialog)
self.qcSig.connect(self.win_query_choice)
self.ynSig.connect(self.win_yes_no_question)
self.win = win
self.device = device
self.dialog = None
@@ -60,6 +62,12 @@ class QtHandlerBase(QObject, PrintError):
self.done.wait()
return self.choice
def yes_no_question(self, msg):
self.done.clear()
self.ynSig.emit(msg)
self.done.wait()
return self.ok
def show_message(self, msg, on_cancel=None):
self.win.emit(SIGNAL('message_dialog'), msg, on_cancel)
@@ -126,3 +134,7 @@ class QtHandlerBase(QObject, PrintError):
def win_query_choice(self, msg, labels):
self.choice = self.win.query_choice(msg, labels)
self.done.set()
def win_yes_no_question(self, msg):
self.ok = self.top_level_window().question(msg)
self.done.set()

View File

@@ -1,7 +1,7 @@
from sys import stderr
from electrum.i18n import _
from electrum.util import PrintError, SilentException
from electrum.util import PrintError, UserCancelled
class GuiMixin(object):
@@ -27,7 +27,7 @@ class GuiMixin(object):
# gets old very quickly, so we suppress those.
if msg.code in (self.types.Failure_PinCancelled,
self.types.Failure_ActionCancelled):
raise SilentException()
raise UserCancelled()
raise RuntimeError(msg.message)
def callback_ButtonRequest(self, msg):

View File

@@ -220,8 +220,6 @@ class TrezorCompatiblePlugin(HW_PluginBase):
process. Then create the wallet accounts.'''
devmgr = self.device_manager()
device_info = devmgr.select_device(wallet, self)
if not device_info:
raise RuntimeError(_("No devices found"))
devmgr.pair_wallet(wallet, device_info.device.id_)
if device_info.initialized:
task = partial(wallet.create_hd_account, None)

View File

@@ -11,9 +11,8 @@ from ..hw_wallet.qt import QtHandlerBase
from electrum.i18n import _
from electrum.plugins import hook, DeviceMgr
from electrum.util import PrintError
from electrum.util import PrintError, UserCancelled
from electrum.wallet import Wallet, BIP44_Wallet
from electrum.wizard import UserCancelled
PASSPHRASE_HELP_SHORT =_(
"Passphrases allow you to access new wallets, each "
@@ -317,10 +316,7 @@ def qt_plugin_class(base_plugin_class):
device_id = self.device_manager().wallet_id(window.wallet)
if not device_id:
info = self.device_manager().select_device(window.wallet, self)
if info:
device_id = info.device.id_
else:
window.wallet.handler.show_error(_("No devices found"))
device_id = info.device.id_
return device_id
def query_choice(self, window, msg, choices):