mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
wizard: better hww debug messages when unpaired_device_infos fails
[DeviceMgr] scanning devices... [DeviceMgr] failed to create client for ledger at b'0002:0007:00': OSError('open failed',) [DeviceMgr] error getting device infos for ledger: open failed ^ GUI did not contain any info about failure
This commit is contained in:
parent
5fc715cdee
commit
f2ad116b0b
2 changed files with 28 additions and 14 deletions
|
@ -233,16 +233,23 @@ class BaseWizard(object):
|
||||||
title = _('Hardware Keystore')
|
title = _('Hardware Keystore')
|
||||||
# check available plugins
|
# check available plugins
|
||||||
supported_plugins = self.plugins.get_hardware_support()
|
supported_plugins = self.plugins.get_hardware_support()
|
||||||
# scan devices
|
|
||||||
devices = [] # type: List[Tuple[str, DeviceInfo]]
|
devices = [] # type: List[Tuple[str, DeviceInfo]]
|
||||||
devmgr = self.plugins.device_manager
|
devmgr = self.plugins.device_manager
|
||||||
|
debug_msg = ''
|
||||||
|
|
||||||
|
def failed_getting_device_infos(name, e):
|
||||||
|
nonlocal debug_msg
|
||||||
|
devmgr.print_error(f'error getting device infos for {name}: {e}')
|
||||||
|
indented_error_msg = ' '.join([''] + str(e).splitlines(keepends=True))
|
||||||
|
debug_msg += f' {name}: (error getting device infos)\n{indented_error_msg}\n'
|
||||||
|
|
||||||
|
# scan devices
|
||||||
try:
|
try:
|
||||||
scanned_devices = devmgr.scan_devices()
|
scanned_devices = devmgr.scan_devices()
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
devmgr.print_error('error scanning devices: {}'.format(repr(e)))
|
devmgr.print_error('error scanning devices: {}'.format(repr(e)))
|
||||||
debug_msg = ' {}:\n {}'.format(_('Error scanning devices'), e)
|
debug_msg = ' {}:\n {}'.format(_('Error scanning devices'), e)
|
||||||
else:
|
else:
|
||||||
debug_msg = ''
|
|
||||||
for splugin in supported_plugins:
|
for splugin in supported_plugins:
|
||||||
name, plugin = splugin.name, splugin.plugin
|
name, plugin = splugin.name, splugin.plugin
|
||||||
# plugin init errored?
|
# plugin init errored?
|
||||||
|
@ -256,14 +263,17 @@ class BaseWizard(object):
|
||||||
# see if plugin recognizes 'scanned_devices'
|
# see if plugin recognizes 'scanned_devices'
|
||||||
try:
|
try:
|
||||||
# FIXME: side-effect: unpaired_device_info sets client.handler
|
# FIXME: side-effect: unpaired_device_info sets client.handler
|
||||||
u = devmgr.unpaired_device_infos(None, plugin, devices=scanned_devices)
|
device_infos = devmgr.unpaired_device_infos(None, plugin, devices=scanned_devices,
|
||||||
|
include_failing_clients=True)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
devmgr.print_error(f'error getting device infos for {name}: {e}')
|
failed_getting_device_infos(name, e)
|
||||||
indented_error_msg = ' '.join([''] + str(e).splitlines(keepends=True))
|
|
||||||
debug_msg += f' {name}: (error getting device infos)\n{indented_error_msg}\n'
|
|
||||||
continue
|
continue
|
||||||
devices += list(map(lambda x: (name, x), u))
|
device_infos_failing = list(filter(lambda di: di.exception is not None, device_infos))
|
||||||
|
for di in device_infos_failing:
|
||||||
|
failed_getting_device_infos(name, di.exception)
|
||||||
|
device_infos_working = list(filter(lambda di: di.exception is None, device_infos))
|
||||||
|
devices += list(map(lambda x: (name, x), device_infos_working))
|
||||||
if not debug_msg:
|
if not debug_msg:
|
||||||
debug_msg = ' {}'.format(_('No exceptions encountered.'))
|
debug_msg = ' {}'.format(_('No exceptions encountered.'))
|
||||||
if not devices:
|
if not devices:
|
||||||
|
|
|
@ -301,8 +301,9 @@ class Device(NamedTuple):
|
||||||
|
|
||||||
class DeviceInfo(NamedTuple):
|
class DeviceInfo(NamedTuple):
|
||||||
device: Device
|
device: Device
|
||||||
label: str
|
label: Optional[str] = None
|
||||||
initialized: bool
|
initialized: Optional[bool] = None
|
||||||
|
exception: Optional[Exception] = None
|
||||||
|
|
||||||
|
|
||||||
class HardwarePluginToScan(NamedTuple):
|
class HardwarePluginToScan(NamedTuple):
|
||||||
|
@ -500,7 +501,8 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
'its seed (and passphrase, if any). Otherwise all bitcoins you '
|
'its seed (and passphrase, if any). Otherwise all bitcoins you '
|
||||||
'receive will be unspendable.').format(plugin.device))
|
'receive will be unspendable.').format(plugin.device))
|
||||||
|
|
||||||
def unpaired_device_infos(self, handler, plugin: 'HW_PluginBase', devices=None):
|
def unpaired_device_infos(self, handler, plugin: 'HW_PluginBase', devices=None,
|
||||||
|
include_failing_clients=False):
|
||||||
'''Returns a list of DeviceInfo objects: one for each connected,
|
'''Returns a list of DeviceInfo objects: one for each connected,
|
||||||
unpaired device accepted by the plugin.'''
|
unpaired device accepted by the plugin.'''
|
||||||
if not plugin.libraries_available:
|
if not plugin.libraries_available:
|
||||||
|
@ -515,14 +517,16 @@ class DeviceMgr(ThreadJob, PrintError):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
client = self.create_client(device, handler, plugin)
|
client = self.create_client(device, handler, plugin)
|
||||||
except UserFacingException:
|
except Exception as e:
|
||||||
raise
|
|
||||||
except BaseException as e:
|
|
||||||
self.print_error(f'failed to create client for {plugin.name} at {device.path}: {repr(e)}')
|
self.print_error(f'failed to create client for {plugin.name} at {device.path}: {repr(e)}')
|
||||||
|
if include_failing_clients:
|
||||||
|
infos.append(DeviceInfo(device=device, exception=e))
|
||||||
continue
|
continue
|
||||||
if not client:
|
if not client:
|
||||||
continue
|
continue
|
||||||
infos.append(DeviceInfo(device, client.label(), client.is_initialized()))
|
infos.append(DeviceInfo(device=device,
|
||||||
|
label=client.label(),
|
||||||
|
initialized=client.is_initialized()))
|
||||||
|
|
||||||
return infos
|
return infos
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue