@ -202,19 +202,26 @@ class TrezorPlugin(HW_PluginBase):
t = threading . Thread ( target = self . _initialize_device_safe , 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 . setDaemon ( True )
t . start ( )
t . start ( )
wizard . loop . exec_ ( )
exit_code = wizard . loop . exec_ ( )
if exit_code != 0 :
# this method (initialize_device) was called with the expectation
# of leaving the device in an initialized state when finishing.
# signal that this is not the case:
raise UserCancelled ( )
wizard . choice_dialog ( title = _ ( ' Initialize Device ' ) , message = msg , choices = choices , run_next = f )
wizard . choice_dialog ( title = _ ( ' Initialize Device ' ) , message = msg , choices = choices , run_next = f )
def _initialize_device_safe ( self , settings , method , device_id , wizard , handler ) :
def _initialize_device_safe ( self , settings , method , device_id , wizard , handler ) :
exit_code = 0
try :
try :
self . _initialize_device ( settings , method , device_id , wizard , handler )
self . _initialize_device ( settings , method , device_id , wizard , handler )
except UserCancelled :
except UserCancelled :
pass
exit_code = 1
except BaseException as e :
except BaseException as e :
traceback . print_exc ( file = sys . stderr )
traceback . print_exc ( file = sys . stderr )
handler . show_error ( str ( e ) )
handler . show_error ( str ( e ) )
exit_code = 1
finally :
finally :
wizard . loop . exit ( 0 )
wizard . loop . exit ( exit_code )
def _initialize_device ( self , settings , method , device_id , wizard , handler ) :
def _initialize_device ( self , settings , method , device_id , wizard , handler ) :
item , label , pin_protection , passphrase_protection , recovery_type = settings
item , label , pin_protection , passphrase_protection , recovery_type = settings