From d19f00b26cd1c4989d448e1436749e6646c1ce95 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 27 Aug 2020 13:44:20 +0200 Subject: [PATCH] python/trezorctl: fix minor bugs in 'set homescreen' --- python/src/trezorlib/cli/settings.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/src/trezorlib/cli/settings.py b/python/src/trezorlib/cli/settings.py index 63e4603a5a..ffa3c036f9 100644 --- a/python/src/trezorlib/cli/settings.py +++ b/python/src/trezorlib/cli/settings.py @@ -38,7 +38,14 @@ def image_to_t1(filename: str) -> bytes: "Image library is missing. Please install via 'pip install Pillow'." ) - image = Image.open(filename) + if filename.endswith(".toif"): + raise click.ClickException("TOIF images not supported on Trezor One") + + try: + image = Image.open(filename) + except Exception as e: + raise click.ClickException("Failed to load image") from e + if image.size != (128, 64): raise click.ClickException("Wrong size of the image - should be 128x64") @@ -73,7 +80,6 @@ def image_to_tt(filename: str) -> bytes: if toif_image.mode != firmware.ToifMode.full_color: raise click.ClickException("Wrong image mode - should be full_color") - toif_image = toif.from_image(image) return toif_image.to_bytes()