From 5c8f357f61c3b57929a8fe48f2164553f2966d21 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Fri, 15 Mar 2024 15:14:07 +1000 Subject: [PATCH] west_commands: sign: suppress imgtool prints If `args.quiet` is set, suppress the useless `print` statements output by `imgtool` (mcuboot script) by capturing `stdout`. Old output: ``` [44/44] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 415192 B 824 KB 49.21% RAM: 163124 B 256 KB 62.23% IDT_LIST: 0 GB 2 KB 0.00% image.py: sign the payload image.py: sign the payload ``` New output: ``` [44/44] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 415192 B 824 KB 49.21% RAM: 163124 B 256 KB 62.23% IDT_LIST: 0 GB 2 KB 0.00% ``` Signed-off-by: Jordan Yates --- scripts/west_commands/sign.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/west_commands/sign.py b/scripts/west_commands/sign.py index fb1de57097..8e9321e46c 100644 --- a/scripts/west_commands/sign.py +++ b/scripts/west_commands/sign.py @@ -299,7 +299,7 @@ class ImgtoolSigner(Signer): log.inf(f'unsigned bin: {in_bin}') log.inf(f'signed bin: {out_bin}') log.dbg(quote_sh_list(sign_bin)) - subprocess.check_call(sign_bin) + subprocess.check_call(sign_bin, stdout=subprocess.PIPE if args.quiet else None) if in_hex: out_hex = args.shex or str(b / 'zephyr' / 'zephyr.signed.hex') sign_hex = sign_base + [in_hex, out_hex] @@ -307,7 +307,7 @@ class ImgtoolSigner(Signer): log.inf(f'unsigned hex: {in_hex}') log.inf(f'signed hex: {out_hex}') log.dbg(quote_sh_list(sign_hex)) - subprocess.check_call(sign_hex) + subprocess.check_call(sign_hex, stdout=subprocess.PIPE if args.quiet else None) @staticmethod def find_imgtool(command, args):