mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
rename post py file
This commit is contained in:
@@ -4,9 +4,15 @@ import sys
|
||||
import shutil
|
||||
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
|
||||
from run_executable import run_with_streaming_input
|
||||
|
||||
|
||||
def get_python_executable():
|
||||
"""Get the appropriate Python executable for the current platform."""
|
||||
# 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):
|
||||
|
||||
# Ensure the output directory exists
|
||||
# Ensure the output directory exists and remove it
|
||||
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):
|
||||
os.remove(output_file_path)
|
||||
|
||||
@@ -41,7 +46,8 @@ def csv_to_md(csv_file_path, output_file_path, script_path):
|
||||
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"):
|
||||
@@ -52,12 +58,14 @@ def main(program_path="./emsesp"):
|
||||
# generate the MD 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
|
||||
test_command = "test telegram_dump"
|
||||
telegram_output_file = os.path.join("docs", "dump_telegrams.csv")
|
||||
print(f"Running test command: telegram_dump > {telegram_output_file}")
|
||||
run_with_streaming_input(program_path, test_command, telegram_output_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get program path from command line argument or use default
|
||||
program_path = sys.argv[1] if len(sys.argv) > 1 else "./emsesp"
|
||||
Reference in New Issue
Block a user