mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 19:00:58 +00:00
python/trezorctl: help user find the right firmware version (fixes #823)
This commit is contained in:
parent
2112da7ab5
commit
b801f1a9cf
@ -94,9 +94,10 @@ def find_best_firmware_version(
|
||||
return ".".join(map(str, version))
|
||||
|
||||
want_version = requested_version
|
||||
highest_version = releases[0]["version"]
|
||||
|
||||
if want_version is None:
|
||||
want_version = releases[0]["version"]
|
||||
want_version = highest_version
|
||||
click.echo("Best available version: {}".format(version_str(want_version)))
|
||||
|
||||
confirm_different_version = False
|
||||
@ -105,7 +106,20 @@ def find_best_firmware_version(
|
||||
try:
|
||||
release = next(r for r in releases if r["version"] == want_version)
|
||||
except StopIteration:
|
||||
click.echo("Version {} not found.".format(want_version_str))
|
||||
click.echo("Version {} not found for your device.".format(want_version_str))
|
||||
|
||||
# look for versions starting with the lowest
|
||||
for release in reversed(releases):
|
||||
closest_version = release["version"]
|
||||
if closest_version > want_version:
|
||||
# stop at first that is higher than the requested
|
||||
break
|
||||
# if there was no break, the newest is used
|
||||
click.echo(
|
||||
"Closest available version: {}".format(version_str(closest_version))
|
||||
)
|
||||
if not beta and want_version > highest_version:
|
||||
click.echo("Hint: specify --beta to look for a beta release.")
|
||||
sys.exit(1)
|
||||
|
||||
if (
|
||||
@ -202,12 +216,22 @@ def firmware_update(
|
||||
f = client.features
|
||||
bootloader_version = (f.major_version, f.minor_version, f.patch_version)
|
||||
bootloader_onev2 = f.major_version == 1 and bootloader_version >= (1, 8, 0)
|
||||
model = client.features.model or "1"
|
||||
|
||||
if filename:
|
||||
data = open(filename, "rb").read()
|
||||
else:
|
||||
if not url:
|
||||
version_list = [int(x) for x in version.split(".")] if version else None
|
||||
if version:
|
||||
version_list = [int(x) for x in version.split(".")]
|
||||
if version_list[0] != bootloader_version[0]:
|
||||
click.echo(
|
||||
"Warning: Trezor {} firmware version should be {}.X.Y (requested: {})".format(
|
||||
model, bootloader_version[0], version
|
||||
)
|
||||
)
|
||||
else:
|
||||
version_list = None
|
||||
url, fp = find_best_firmware_version(
|
||||
list(bootloader_version), version_list, beta, bitcoin_only
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user