rename post py file

This commit is contained in:
proddy
2025-10-25 09:53:08 +02:00
parent 353cdb324d
commit a2823563bf

View File

@@ -4,9 +4,15 @@ import sys
import shutil import shutil
from pathlib import Path from pathlib import Path
# This creates the files
# - dump_entities.csv
# - Modbus-Entity-Registers.md
# - dump_telegrams.csv
# Import the streaming function from the separate module # Import the streaming function from the separate module
from run_executable import run_with_streaming_input from run_executable import run_with_streaming_input
def get_python_executable(): def get_python_executable():
"""Get the appropriate Python executable for the current platform.""" """Get the appropriate Python executable for the current platform."""
# Try different Python executable names # Try different Python executable names
@@ -22,10 +28,9 @@ def get_python_executable():
def csv_to_md(csv_file_path, output_file_path, script_path): def csv_to_md(csv_file_path, output_file_path, script_path):
# Ensure the output directory exists # Ensure the output directory exists and remove it
Path(output_file_path).parent.mkdir(parents=True, exist_ok=True) Path(output_file_path).parent.mkdir(parents=True, exist_ok=True)
# delete the output file if it exists
if os.path.exists(output_file_path): if os.path.exists(output_file_path):
os.remove(output_file_path) os.remove(output_file_path)
@@ -41,7 +46,8 @@ def csv_to_md(csv_file_path, output_file_path, script_path):
check=True check=True
) )
print(f"Generated MD file: {output_file_path} ({os.path.getsize(output_file_path)} bytes)") print(
f"Generated MD file: {output_file_path} ({os.path.getsize(output_file_path)} bytes)")
def main(program_path="./emsesp"): def main(program_path="./emsesp"):
@@ -52,12 +58,14 @@ def main(program_path="./emsesp"):
# generate the MD file # generate the MD file
csv_to_md(csv_file, output_file, script_file) csv_to_md(csv_file, output_file, script_file)
# final step is to run the telegram_dump test command and generate the dump_telegrams.csv file
# run the test command and generate the dump_telegrams.csv file # run the test command and generate the dump_telegrams.csv file
test_command = "test telegram_dump" test_command = "test telegram_dump"
telegram_output_file = os.path.join("docs", "dump_telegrams.csv") telegram_output_file = os.path.join("docs", "dump_telegrams.csv")
print(f"Running test command: telegram_dump > {telegram_output_file}") print(f"Running test command: telegram_dump > {telegram_output_file}")
run_with_streaming_input(program_path, test_command, telegram_output_file) run_with_streaming_input(program_path, test_command, telegram_output_file)
if __name__ == "__main__": if __name__ == "__main__":
# Get program path from command line argument or use default # Get program path from command line argument or use default
program_path = sys.argv[1] if len(sys.argv) > 1 else "./emsesp" program_path = sys.argv[1] if len(sys.argv) > 1 else "./emsesp"