1
0
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:
matejcik 2019-08-06 15:49:56 +02:00 committed by matejcik
parent 2f7b2da2e3
commit 842fde455c

View File

@ -30,23 +30,23 @@ TREZOR_VERSION = None
def get_device(): def get_device():
path = os.environ.get("TREZOR_PATH") path = os.environ.get("TREZOR_PATH")
interact = int(os.environ.get("INTERACT", 0))
if path: if path:
transport = get_transport(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: else:
devices = enumerate_devices() devices = enumerate_devices()
for device in devices: for device in devices:
if hasattr(device, "find_debug"): try:
transport = device return TrezorClientDebugLink(device, auto_interact=not interact)
break except Exception:
pass
else: else:
raise RuntimeError("No debuggable device found") 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(): def device_version():