Respect ESPHOME_USE_SUBPROCESS in esp32 post_build script (#3246)

This commit is contained in:
Martin Weinelt 2022-02-21 02:05:13 +01:00 committed by Jesse Hills
parent 138d6e505b
commit 3d0899aa58
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A

View File

@ -1,6 +1,10 @@
# Source https://github.com/letscontrolit/ESPEasy/pull/3845#issuecomment-1005864664 # Source https://github.com/letscontrolit/ESPEasy/pull/3845#issuecomment-1005864664
import esptool import os
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
import esptool
else:
import subprocess
from SCons.Script import ARGUMENTS from SCons.Script import ARGUMENTS
# pylint: disable=E0602 # pylint: disable=E0602
@ -42,8 +46,11 @@ def esp32_create_combined_bin(source, target, env):
print() print()
print(f"Using esptool.py arguments: {' '.join(cmd)}") print(f"Using esptool.py arguments: {' '.join(cmd)}")
print() print()
esptool.main(cmd)
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
esptool.main(cmd)
else:
subprocess.run(["esptool.py", *cmd])
# pylint: disable=E0602 # pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa