Skip to content

Commit

Permalink
Enhanced Python scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gjroots committed Aug 27, 2023
1 parent c6ff6aa commit 533d5e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
18 changes: 13 additions & 5 deletions post_extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ def copy_files():
]
for src, dest in files:
shutil.copyfile(src, f'release/{dest}')
print("==========> Bin files are copied to the /release folder.")
print("==========> Bin files are copied to the /release folder.\n")


def convert_single_bin():
build_dir = env.subst("$BUILD_DIR")
binary_path = os.path.join(build_dir, "firmware.bin")
bootloader_path = os.path.join(build_dir, "bootloader.bin")
partitions_path = os.path.join(build_dir, "partitions.bin")
release_path = os.path.join(env.subst("$PROJECT_DIR"), "release")
merged_file = os.path.join(release_path, f"esp32nat_Router+_full_v{version}_0x0.bin")
esptool_dir = env.PioPlatform().get_package_dir("tool-esptoolpy")
esptool_command = f'python {str(esptool_dir)}\\esptool.py --chip esp32 merge_bin -o {merged_file} --flash_freq 40m --flash_size 4MB 0x1000 {bootloader_path} 0x8000 {partitions_path} 0x10000 {binary_path}'

os.makedirs("release", exist_ok=True)
os.system(
f'esptool.py --chip esp32 merge_bin -o release/esp32nat_Router+_full_v{version}_0x0.bin --flash_freq 40m --flash_size 4MB 0x1000 release/bootloader.bin 0x10000 release/esp32nat_Router+_v{version}.bin 0x8000 release/partitions.bin')
env.Execute(esptool_command)
zip_all_bins()


Expand All @@ -47,7 +55,7 @@ def zip_all_bins():
zipObj.write(
f'release/esp32nat_Router+_full_v{version}_0x0.bin', f'esp32nat_Router+_full_v{version}_0x0.bin')

print("==========> zip files created successfully")
print("\n==========> zip files created successfully")


def after_build_program(source, target, env):
Expand All @@ -57,4 +65,4 @@ def after_build_program(source, target, env):
convert_single_bin()


env.AddPostAction("$BUILD_DIR/firmware.bin", after_build_program)
env.AddPostAction("buildprog", after_build_program)
18 changes: 10 additions & 8 deletions pre_extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import gzip
import re
import platform

print("\033[94m╔═╗┌─┐┌─┐ ╔╗╔┌─┐┌┬┐ ╦═╗┌─┐┬ ┬┌┬┐┌─┐┬─┐ _|_\n║╣ └─┐├─┘32─║║║├─┤ │ ╠╦╝│ ││ │ │ ├┤ ├┬┘ | \n╚═╝└─┘┴ ╝╚╝┴ ┴ ┴ ╩╚═└─┘└─┘ ┴ └─┘┴└─\033[0m\n")

Expand All @@ -14,6 +15,7 @@
version = config.get("extra_script_settings", "version")

jekyll_install_status = False
system_platform = platform.system()

if os.system('jekyll -v') == 0:
# print('Jekyll is installed on your system.')
Expand All @@ -22,14 +24,14 @@
print(
'\033[91mJekyll is not installed on your system. Please install Jekyll.\033[0m')


# uncomment for linux and git bash users
# def build_site():
# env.Execute("build_web_pages.sh")

# for windows user
def build_site():
env.Execute("build_web_pages.bat")
if system_platform =="Linux":
# for linux user
def build_site():
env.Execute("build_web_pages.sh")
elif system_platform == "Windows":
# for windows user
def build_site():
env.Execute("build_web_pages.bat")


base_folder_path = './components/web_server/www/'
Expand Down

0 comments on commit 533d5e9

Please sign in to comment.