diff --git a/scoreboard/CMakeLists.txt b/scoreboard/CMakeLists.txt index 1362ef99f..b53310abe 100644 --- a/scoreboard/CMakeLists.txt +++ b/scoreboard/CMakeLists.txt @@ -11,10 +11,3 @@ add_custom_target( ${OUTPUT_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Running main.py") - -add_custom_command( - TARGET generate_scoreboard - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/static - ${OUTPUT_DIR}/static - COMMENT "Copying static directory to binary directory") diff --git a/scoreboard/main.py b/scoreboard/main.py index 8dab34ea5..dceaf820f 100644 --- a/scoreboard/main.py +++ b/scoreboard/main.py @@ -5,6 +5,7 @@ import argparse import subprocess import yaml +import shutil from jinja2 import Environment, FileSystemLoader import logging @@ -228,10 +229,22 @@ def main(): ) args = parser.parse_args() - output_file = Path(args.output) / "index.html" + output_path = Path(args.output) + output_path.mkdir(parents=True, exist_ok=True) + output_file = output_path / "index.html" with open(output_file, "w") as file: file.write(html_content) + static_src = script_dir / "static" + static_dst = output_path / "static" + if static_src.exists(): + if static_dst.exists(): + shutil.rmtree(static_dst) + shutil.copytree(static_src, static_dst) + logger.info("Static directory copied to %s", static_dst) + else: + logger.warning("Static directory not found at %s", static_src) + logger.info("HTML page generated at %s", output_file)