Skip to content

Commit 533d5e9

Browse files
committed
Enhanced Python scripts
1 parent c6ff6aa commit 533d5e9

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

Diff for: post_extra_script.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ def copy_files():
2222
]
2323
for src, dest in files:
2424
shutil.copyfile(src, f'release/{dest}')
25-
print("==========> Bin files are copied to the /release folder.")
25+
print("==========> Bin files are copied to the /release folder.\n")
2626

2727

2828
def convert_single_bin():
29+
build_dir = env.subst("$BUILD_DIR")
30+
binary_path = os.path.join(build_dir, "firmware.bin")
31+
bootloader_path = os.path.join(build_dir, "bootloader.bin")
32+
partitions_path = os.path.join(build_dir, "partitions.bin")
33+
release_path = os.path.join(env.subst("$PROJECT_DIR"), "release")
34+
merged_file = os.path.join(release_path, f"esp32nat_Router+_full_v{version}_0x0.bin")
35+
esptool_dir = env.PioPlatform().get_package_dir("tool-esptoolpy")
36+
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}'
37+
2938
os.makedirs("release", exist_ok=True)
30-
os.system(
31-
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')
39+
env.Execute(esptool_command)
3240
zip_all_bins()
3341

3442

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

50-
print("==========> zip files created successfully")
58+
print("\n==========> zip files created successfully")
5159

5260

5361
def after_build_program(source, target, env):
@@ -57,4 +65,4 @@ def after_build_program(source, target, env):
5765
convert_single_bin()
5866

5967

60-
env.AddPostAction("$BUILD_DIR/firmware.bin", after_build_program)
68+
env.AddPostAction("buildprog", after_build_program)

Diff for: pre_extra_script.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import gzip
55
import re
6+
import platform
67

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

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

1617
jekyll_install_status = False
18+
system_platform = platform.system()
1719

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

25-
26-
# uncomment for linux and git bash users
27-
# def build_site():
28-
# env.Execute("build_web_pages.sh")
29-
30-
# for windows user
31-
def build_site():
32-
env.Execute("build_web_pages.bat")
27+
if system_platform =="Linux":
28+
# for linux user
29+
def build_site():
30+
env.Execute("build_web_pages.sh")
31+
elif system_platform == "Windows":
32+
# for windows user
33+
def build_site():
34+
env.Execute("build_web_pages.bat")
3335

3436

3537
base_folder_path = './components/web_server/www/'

0 commit comments

Comments
 (0)