Files
nuki_hub/updater/pio_package.py
iranl 1f4e85a09e Remove Solo1 support + validate HTTPS certs on HTTPS requests (#443)
* Use esp_crt_bundle for HTTPS requests

* Remove Solo1 support
2024-08-08 17:29:48 +07:00

43 lines
1.1 KiB
Python

""" PlatformIO POST script execution to copy updater """
Import("env")
import glob
import os
import shutil
from pathlib import Path
def get_board_name(env):
board = env.get('BOARD_MCU')
return board
def create_target_dir(env):
board = get_board_name(env)
target_dir = env.GetProjectOption("custom_build") + '/' + board
if not os.path.exists(target_dir):
os.makedirs(target_dir)
return target_dir
def copy_files(source, target, env):
file = Path(target[0].get_abspath())
target_dir = create_target_dir(env)
board = get_board_name(env)
if "firmware" in file.stem:
shutil.copy(file, f"{target_dir}/updater.bin")
def remove_files(source, target, env):
for f in glob.glob("src/*.cpp"):
os.remove(f)
for f in glob.glob("src/*.h"):
os.remove(f)
for f in glob.glob("src/networkDevices/*.cpp"):
os.remove(f)
for f in glob.glob("src/networkDevices/*.h"):
os.remove(f)
env.AddPostAction("$BUILD_DIR/firmware.bin", copy_files)
env.AddPostAction("$BUILD_DIR/firmware.bin", remove_files)