From 4fd6694efcff79078382819eb266c11f1352c99a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 21 Mar 2023 17:26:22 +0100 Subject: [PATCH] prevent crash when no firmware exits --- pio-tools/set_partition_table.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pio-tools/set_partition_table.py b/pio-tools/set_partition_table.py index e8708609f..364d55d60 100644 --- a/pio-tools/set_partition_table.py +++ b/pio-tools/set_partition_table.py @@ -24,10 +24,11 @@ if "nobuild" in COMMAND_LINE_TARGETS: source_firm = join(env.subst("$PROJECT_DIR"), "build_output","firmware",firm_name) if not os.path.exists(join(env.subst("$BUILD_DIR"))): os.makedirs(join(env.subst("$BUILD_DIR"))) - shutil.copy(source_firm, join(env.subst("$BUILD_DIR"))) - target_ren = join(env.subst("$BUILD_DIR"), firm_name) - renamed = join(env.subst("$BUILD_DIR"), "firmware.bin") - os.rename(target_ren, renamed) + if os.path.isfile(source_firm): + shutil.copy(source_firm, join(env.subst("$BUILD_DIR"))) + target_ren = join(env.subst("$BUILD_DIR"), firm_name) + renamed = join(env.subst("$BUILD_DIR"), "firmware.bin") + os.rename(target_ren, renamed) if env["PIOPLATFORM"] != "espressif32": framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266")