1
0

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:
SomberNight
2019-01-21 18:44:36 +01:00
parent 5fc715cdee
commit f2ad116b0b
2 changed files with 28 additions and 14 deletions

View File

@@ -301,8 +301,9 @@ class Device(NamedTuple):
class DeviceInfo(NamedTuple):
device: Device
label: str
initialized: bool
label: Optional[str] = None
initialized: Optional[bool] = None
exception: Optional[Exception] = None
class HardwarePluginToScan(NamedTuple):
@@ -500,7 +501,8 @@ class DeviceMgr(ThreadJob, PrintError):
'its seed (and passphrase, if any). Otherwise all bitcoins you '
'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,
unpaired device accepted by the plugin.'''
if not plugin.libraries_available:
@@ -515,14 +517,16 @@ class DeviceMgr(ThreadJob, PrintError):
continue
try:
client = self.create_client(device, handler, plugin)
except UserFacingException:
raise
except BaseException as e:
except Exception as 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
if not client:
continue
infos.append(DeviceInfo(device, client.label(), client.is_initialized()))
infos.append(DeviceInfo(device=device,
label=client.label(),
initialized=client.is_initialized()))
return infos