From 25c85a90ac877399cc613e893551b65a53362807 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 19 Jun 2025 20:19:37 +0200 Subject: [PATCH] esptool v5 explicit exists (#23576) fetch the exit to prevent leaving the running script --- pio-tools/post_esp32.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index a3023101b..6992f45b0 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -85,6 +85,17 @@ if not variants_dir: variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") env.BoardConfig().update("build.variants_dir", variants_dir) +def esptool_call(cmd): + try: + esptool.main(cmd) + except SystemExit as e: + # Fetch sys.exit() without leaving the script + if e.code == 0: + return True + else: + print(f"❌ esptool failed with exit code: {e.code}") + return False + def esp32_detect_flashsize(): uploader = env.subst("$UPLOADER") if not "upload" in COMMAND_LINE_TARGETS: @@ -339,7 +350,7 @@ def esp32_create_combined_bin(source, target, env): sys.stdout = devnull sys.stderr = devnull try: - esptool.main(cmd) + esptool_call(cmd) finally: sys.stdout = old_stdout sys.stderr = old_stderr