DeviceMgr.select_device: add some log lines
related https://github.com/spesmilo/electrum/issues/5759#issuecomment-1060093399
This commit is contained in:
@@ -648,6 +648,7 @@ class DeviceMgr(ThreadJob):
|
||||
if keystore.soft_device_id:
|
||||
for info in infos:
|
||||
if info.soft_device_id == keystore.soft_device_id:
|
||||
self.logger.debug(f"select_device. auto-selected(1) {plugin.device}: soft_device_id matched")
|
||||
return info
|
||||
# method 2: select device by label
|
||||
# but only if not a placeholder label and only if there is no collision
|
||||
@@ -656,14 +657,17 @@ class DeviceMgr(ThreadJob):
|
||||
and device_labels.count(keystore.label) == 1):
|
||||
for info in infos:
|
||||
if info.label == keystore.label:
|
||||
self.logger.debug(f"select_device. auto-selected(2) {plugin.device}: label recognised")
|
||||
return info
|
||||
# method 3: if there is only one device connected, and we don't have useful label/soft_device_id
|
||||
# saved for keystore anyway, select it
|
||||
if (len(infos) == 1
|
||||
and keystore.label in PLACEHOLDER_HW_CLIENT_LABELS
|
||||
and keystore.soft_device_id is None):
|
||||
self.logger.debug(f"select_device. auto-selected(3) {plugin.device}: only one device")
|
||||
return infos[0]
|
||||
|
||||
self.logger.debug(f"select_device. auto-select failed for {plugin.device}. {allow_user_interaction=}")
|
||||
if not allow_user_interaction:
|
||||
raise CannotAutoSelectDevice()
|
||||
# ask user to select device manually
|
||||
@@ -674,10 +678,13 @@ class DeviceMgr(ThreadJob):
|
||||
transport=info.device.transport_ui_string,
|
||||
maybe_model=f"{info.model_name}, " if info.model_name else "")
|
||||
for info in infos]
|
||||
self.logger.debug(f"select_device. prompting user for manual selection of {plugin.device}. "
|
||||
f"num options: {len(infos)}. options: {infos}")
|
||||
c = handler.query_choice(msg, descriptions)
|
||||
if c is None:
|
||||
raise UserCancelled()
|
||||
info = infos[c]
|
||||
self.logger.debug(f"select_device. user manually selected {plugin.device}. device info: {info}")
|
||||
# note: updated label/soft_device_id will be saved after pairing succeeds
|
||||
return info
|
||||
|
||||
|
||||
Reference in New Issue
Block a user