Coverage for melissa/utility/client_scripts.py: 67%

12 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2025-11-03 09:52 +0100

1import os 

2import re 

3 

4 

5CLIENT_SCRIPTS_DIR = "./client_scripts" 

6 

7 

8def get_client_script_root_dir() -> str: 

9 return CLIENT_SCRIPTS_DIR 

10 

11 

12def get_available_client_script_path(sim_id: int) -> str: 

13 """Searches for the script corresponding to the given sim_id.""" 

14 for filename in os.listdir(CLIENT_SCRIPTS_DIR): 

15 if re.match(rf"client(\.\d+)?(B?)\.{sim_id}\.sh", filename): 

16 return os.path.join(CLIENT_SCRIPTS_DIR, filename) 

17 raise FileNotFoundError(f"No script found for sim_id: {sim_id}") 

18 

19 

20def get_client_script_path(sim_id: int) -> str: 

21 """Returns the absolute path to the client script for the given simulation ID.""" 

22 return f"{CLIENT_SCRIPTS_DIR}/client.{sim_id}.sh"