This commit is contained in:
Jason2866 2024-02-29 18:23:33 +01:00 committed by GitHub
parent adfbf6508a
commit 3c43486cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import os
import shutil import shutil
import tasmotapiolib import tasmotapiolib
import gzip import gzip
from colorama import Fore, Back, Style
def map_gzip(source, target, env): def map_gzip(source, target, env):
# create string with location and file names based on variant # create string with location and file names based on variant
@ -50,14 +51,12 @@ if tasmotapiolib.is_env_set(tasmotapiolib.ENABLE_ESP32_GZ, env) or env["PIOPLATF
GZ_FIRMWARE_SIZE = gzip_file.stat().st_size GZ_FIRMWARE_SIZE = gzip_file.stat().st_size
if ORG_FIRMWARE_SIZE > 995326 and env["PIOPLATFORM"] != "espressif32": if ORG_FIRMWARE_SIZE > 995326 and env["PIOPLATFORM"] != "espressif32":
print( print(Fore.RED + "!!! Tasmota firmware size is too big with {} bytes. Max size is 995326 bytes !!! ".format(
"\u001b[31;1m!!! Tasmota firmware size is too big with {} bytes. Max size is 995326 bytes !!! \u001b[0m".format(
ORG_FIRMWARE_SIZE ORG_FIRMWARE_SIZE
) )
) )
else: else:
print( print(Fore.GREEN + "Compression reduced firmware size to {:.0f}% (was {} bytes, now {} bytes)".format(
"Compression reduced firmware size to {:.0f}% (was {} bytes, now {} bytes)".format(
(GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, (GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100,
ORG_FIRMWARE_SIZE, ORG_FIRMWARE_SIZE,
GZ_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE,

View File

@ -4,30 +4,31 @@ import os
import pathlib import pathlib
from os.path import join from os.path import join
import shutil import shutil
from colorama import Fore, Back, Style
if " " in join(pathlib.Path(env["PROJECT_DIR"])): if " " in join(pathlib.Path(env["PROJECT_DIR"])):
print ("\u001b[31;1m*** Whitespace(s) in project path, unexpected issues/errors can happen ***\u001b[0m") print(Fore.RED + "*** Whitespace(s) in project path, unexpected issues/errors can happen ***")
# copy tasmota/user_config_override_sample.h to tasmota/user_config_override.h # copy tasmota/user_config_override_sample.h to tasmota/user_config_override.h
if os.path.isfile("tasmota/user_config_override.h"): if os.path.isfile("tasmota/user_config_override.h"):
print ("*** use provided user_config_override.h as planned ***") print(Fore.GREEN + "*** use provided user_config_override.h as planned ***")
else: else:
shutil.copy("tasmota/user_config_override_sample.h", "tasmota/user_config_override.h") shutil.copy("tasmota/user_config_override_sample.h", "tasmota/user_config_override.h")
# copy platformio_override_sample.ini to platformio_override.ini # copy platformio_override_sample.ini to platformio_override.ini
if os.path.isfile("platformio_override.ini"): if os.path.isfile("platformio_override.ini"):
print ("*** use provided platformio_override.ini as planned ***") print(Fore.GREEN + "*** use provided platformio_override.ini as planned ***")
else: else:
shutil.copy("platformio_override_sample.ini", "platformio_override.ini") shutil.copy("platformio_override_sample.ini", "platformio_override.ini")
# copy platformio_tasmota_cenv_sample.ini to platformio_tasmota_cenv.ini # copy platformio_tasmota_cenv_sample.ini to platformio_tasmota_cenv.ini
if os.path.isfile("platformio_tasmota_cenv.ini"): if os.path.isfile("platformio_tasmota_cenv.ini"):
print ("*** use provided platformio_tasmota_cenv.ini as planned ***") print(Fore.GREEN + "*** use provided platformio_tasmota_cenv.ini as planned ***")
else: else:
shutil.copy("platformio_tasmota_cenv_sample.ini", "platformio_tasmota_cenv.ini") shutil.copy("platformio_tasmota_cenv_sample.ini", "platformio_tasmota_cenv.ini")
# copy platformio_tasmota_core3_env_sample.ini to platformio_tasmota_core3_env.ini # copy platformio_tasmota_core3_env_sample.ini to platformio_tasmota_core3_env.ini
if os.path.isfile("platformio_tasmota_core3_env.ini"): if os.path.isfile("platformio_tasmota_core3_env.ini"):
print ("*** use provided platformio_tasmota_core3_env.ini as planned ***") print(Fore.GREEN + "*** use provided platformio_tasmota_core3_env.ini as planned ***")
else: else:
shutil.copy("platformio_tasmota_core3_env_sample.ini", "platformio_tasmota_core3_env.ini") shutil.copy("platformio_tasmota_core3_env_sample.ini", "platformio_tasmota_core3_env.ini")

View File

@ -103,7 +103,7 @@ def esp32_detect_flashsize():
return size, True return size, True
return "4MB",False return "4MB",False
except subprocess.CalledProcessError as exc: except subprocess.CalledProcessError as exc:
print("Did get chip info failed with " + str(exc)) print(Fore.YELLOW + "Did get chip info failed with " + str(exc))
return "4MB",False return "4MB",False
flash_size_from_esp, flash_size_was_overridden = esp32_detect_flashsize() flash_size_from_esp, flash_size_was_overridden = esp32_detect_flashsize()
@ -166,7 +166,7 @@ def esp32_build_filesystem(fs_size):
print("Renaming",(file.split(os.path.sep)[-1]).split(" ")[0],"to",file.split(" ")[1]) print("Renaming",(file.split(os.path.sep)[-1]).split(" ")[0],"to",file.split(" ")[1])
open(target, "wb").write(response.content) open(target, "wb").write(response.content)
else: else:
print("Failed to download: ",file) print(Fore.RED + "Failed to download: ",file)
continue continue
if os.path.isdir(file): if os.path.isdir(file):
shutil.copytree(file, filesystem_dir, dirs_exist_ok=True) shutil.copytree(file, filesystem_dir, dirs_exist_ok=True)