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
pull/404/head
matejcik 5 years ago committed by matejcik
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:
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:
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…
Cancel
Save