mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
tests: improve debug-trezor detection
should (finally) work with a connected production Trezor and an emulator, in which case it should pick the emulator by itself
This commit is contained in:
parent
2f7b2da2e3
commit
842fde455c
@ -30,23 +30,23 @@ TREZOR_VERSION = None
|
||||
|
||||
def get_device():
|
||||
path = os.environ.get("TREZOR_PATH")
|
||||
interact = int(os.environ.get("INTERACT", 0))
|
||||
if path:
|
||||
try:
|
||||
transport = get_transport(path)
|
||||
return TrezorClientDebugLink(transport, auto_interact=not interact)
|
||||
except Exception as e:
|
||||
raise RuntimeError("Failed to open debuglink for {}".format(path)) from e
|
||||
|
||||
else:
|
||||
devices = enumerate_devices()
|
||||
for device in devices:
|
||||
if hasattr(device, "find_debug"):
|
||||
transport = device
|
||||
break
|
||||
try:
|
||||
return TrezorClientDebugLink(device, auto_interact=not interact)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError("No debuggable device found")
|
||||
env_interactive = int(os.environ.get("INTERACT", 0))
|
||||
try:
|
||||
return TrezorClientDebugLink(transport, auto_interact=not env_interactive)
|
||||
except Exception as e:
|
||||
raise RuntimeError(
|
||||
"Failed to open debuglink for {}".format(transport.get_path())
|
||||
) from e
|
||||
|
||||
|
||||
def device_version():
|
||||
|
Loading…
Reference in New Issue
Block a user