Index: suite_leahi/shared/scripts/configuration/application_init.py =================================================================== diff -u -r742f5ee77d1f59bf553700dd433779b4d0a22be0 -r53c5b62d1fbf9121df012d6c025f482bfd3826b0 --- suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 742f5ee77d1f59bf553700dd433779b4d0a22be0) +++ suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 53c5b62d1fbf9121df012d6c025f482bfd3826b0) @@ -1,10 +1,12 @@ import test import sys import os - +import glob +import subprocess +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) @@ -140,3 +170,20 @@ return True except: return False + +def get_aut_version(aut_path): + """ + Executes the AUT with the --version argument and captures the output. + """ + actual_aut_path = os.path.join(aut_path, "leahi") + command = [actual_aut_path, "--version"] + # Running the command and capturing the output. + result = subprocess.run( + command, + capture_output=True, + text=True, + ) + aut_name_and_version = result.stdout.strip() + aut_version = aut_name_and_version.split(" ") + aut_version_only = aut_version[1] + return aut_version_only