Index: suite_leahi/shared/scripts/configuration/application_init.py =================================================================== diff -u -re74e550d3abff8c854a63ed41d5b01d78b110094 -r0bb330c1823aad987899f72b12c302551d575c5a --- suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision e74e550d3abff8c854a63ed41d5b01d78b110094) +++ suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 0bb330c1823aad987899f72b12c302551d575c5a) @@ -1,10 +1,12 @@ import test import sys import os +import glob +from pathlib import Path from leahi_dialin.ui import utils -from configuration import config -from configuration import utility +from configuration import config +from configuration import utility # WARNING: these variables has to match with the ones in the run.sh and in UI code POSTMSG_POSTFIX_PASSED = " passed" @@ -25,7 +27,35 @@ _devBluetooth = "hci0:" _yearMinimum = 2022 # The year to check for minimum + +def delete_existing_files_usb_folders(): + base_path = Path.home() / "Desktop/usb-disk" + + cleanup_targets = { + base_path / "log": ["*.log"], + base_path / "service": ["*.err"] + } + + for folder, extensions in cleanup_targets.items(): + if not folder.is_dir(): + test.log(f"Warning: Directory '{folder}' not found. Skipping.") + continue + + found = False + for ext in extensions: + for file_path in folder.glob(ext): + try: + os.remove(file_path) + found = True + except OSError as e: + test.log(f" Error deleting file {file_path}: {e}") + + if not found: + test.log("No matching files found.") + + test.log("Cleanup complete.") + def remove_mock_app_post_log_file(): if os.path.exists(config.APP_POST_LOG_LOCATION): os.remove(config.APP_POST_LOG_LOCATION)