URI: 
       ttrezor/keepkey: catch exception during device init - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit ba7d905dfbf30b0204fdf9aa461c59e699f63e16
   DIR parent fcfe3406b33e6a8304d91d22fe84ef87883d461f
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Tue,  1 May 2018 14:35:55 +0200
       
       ttrezor/keepkey: catch exception during device init
       
       Diffstat:
         M plugins/keepkey/plugin.py           |      14 ++++++++++++--
         M plugins/trezor/trezor.py            |      14 ++++++++++++--
       
       2 files changed, 24 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/plugins/keepkey/plugin.py b/plugins/keepkey/plugin.py
       t@@ -1,4 +1,6 @@
        from binascii import hexlify, unhexlify
       +import traceback
       +import sys
        
        from electrum.util import bfh, bh2u
        from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
       t@@ -161,12 +163,21 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
                def f(method):
                    import threading
                    settings = self.request_trezor_init_settings(wizard, method, self.device)
       -            t = threading.Thread(target = self._initialize_device, args=(settings, method, device_id, wizard, handler))
       +            t = threading.Thread(target=self._initialize_device_safe, args=(settings, method, device_id, wizard, handler))
                    t.setDaemon(True)
                    t.start()
                    wizard.loop.exec_()
                wizard.choice_dialog(title=_('Initialize Device'), message=msg, choices=choices, run_next=f)
        
       +    def _initialize_device_safe(self, settings, method, device_id, wizard, handler):
       +        try:
       +            self._initialize_device(settings, method, device_id, wizard, handler)
       +        except BaseException as e:
       +            traceback.print_exc(file=sys.stderr)
       +            handler.show_error(str(e))
       +        finally:
       +            wizard.loop.exit(0)
       +
            def _initialize_device(self, settings, method, device_id, wizard, handler):
                item, label, pin_protection, passphrase_protection = settings
        
       t@@ -192,7 +203,6 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
                    pin = pin_protection  # It's the pin, not a boolean
                    client.load_device_by_xprv(item, pin, passphrase_protection,
                                               label, language)
       -        wizard.loop.exit(0)
        
            def setup_device(self, device_info, wizard, purpose):
                devmgr = self.device_manager()
   DIR diff --git a/plugins/trezor/trezor.py b/plugins/trezor/trezor.py
       t@@ -1,4 +1,6 @@
        from binascii import hexlify, unhexlify
       +import traceback
       +import sys
        
        from electrum.util import bfh, bh2u, versiontuple
        from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
       t@@ -196,12 +198,21 @@ class TrezorPlugin(HW_PluginBase):
                def f(method):
                    import threading
                    settings = self.request_trezor_init_settings(wizard, method, self.device)
       -            t = threading.Thread(target = self._initialize_device, args=(settings, method, device_id, wizard, handler))
       +            t = threading.Thread(target=self._initialize_device_safe, args=(settings, method, device_id, wizard, handler))
                    t.setDaemon(True)
                    t.start()
                    wizard.loop.exec_()
                wizard.choice_dialog(title=_('Initialize Device'), message=msg, choices=choices, run_next=f)
        
       +    def _initialize_device_safe(self, settings, method, device_id, wizard, handler):
       +        try:
       +            self._initialize_device(settings, method, device_id, wizard, handler)
       +        except BaseException as e:
       +            traceback.print_exc(file=sys.stderr)
       +            handler.show_error(str(e))
       +        finally:
       +            wizard.loop.exit(0)
       +
            def _initialize_device(self, settings, method, device_id, wizard, handler):
                item, label, pin_protection, passphrase_protection = settings
        
       t@@ -240,7 +251,6 @@ class TrezorPlugin(HW_PluginBase):
                    pin = pin_protection  # It's the pin, not a boolean
                    client.load_device_by_xprv(item, pin, passphrase_protection,
                                               label, language)
       -        wizard.loop.exit(0)
        
            def setup_device(self, device_info, wizard, purpose):
                devmgr = self.device_manager()