From 7b87648fa819025054939467c1f85207bcc9933d Mon Sep 17 00:00:00 2001 From: Jeremiah K <17190268+jeremiah-k@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:32:40 -0600 Subject: [PATCH] Remove command output txt file on c-wrapper start --- app/command_wrapper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/command_wrapper.py b/app/command_wrapper.py index 53c6d94..e36eec6 100644 --- a/app/command_wrapper.py +++ b/app/command_wrapper.py @@ -2,10 +2,15 @@ import os import subprocess import time +output_file = '/home/mesh/app/command_output.txt' flag_file = '/home/mesh/app/.commands_executed' +# Remove the output file if it exists +if os.path.exists(output_file): + os.remove(output_file) + def log_to_file(message): - with open('/home/mesh/app/command_output.txt', 'a') as f: + with open(output_file, 'a') as f: f.write(message + "\n") def execute_meshtastic_command(options): @@ -36,4 +41,4 @@ else: # Create the flag file to indicate that all commands have been executed. with open(flag_file, 'w') as f: f.write("Commands executed on: " + time.ctime()) - break + break \ No newline at end of file