aegis_gui.utilities.ps_list
1import re 2import psutil 3import logging 4from typing import Set 5 6 7def run_ps_af() -> Set[str]: 8 """Returns names of simulations whose processes are currently running based on the OS.""" 9 config_files = set() 10 try: 11 # Define the pattern for matching process command lines 12 pattern = re.compile(r"python3 -m aegis --config_path .*/(.*)\.yml") 13 14 # Iterate through all running processes 15 for proc in psutil.process_iter(["cmdline"]): 16 try: 17 # Get the command line arguments of the process 18 cmdline = " ".join(proc.info["cmdline"]) 19 20 # Match the command line with the pattern 21 match = pattern.search(cmdline) 22 if match: 23 config_file = match.group(1) 24 config_files.add(config_file) 25 except (psutil.NoSuchProcess, psutil.AccessDenied): 26 # Process has been terminated or we don't have permission to access it 27 continue 28 29 except Exception as e: 30 logging.error(f"An error occurred: {e}") 31 32 return config_files
def
run_ps_af() -> Set[str]:
8def run_ps_af() -> Set[str]: 9 """Returns names of simulations whose processes are currently running based on the OS.""" 10 config_files = set() 11 try: 12 # Define the pattern for matching process command lines 13 pattern = re.compile(r"python3 -m aegis --config_path .*/(.*)\.yml") 14 15 # Iterate through all running processes 16 for proc in psutil.process_iter(["cmdline"]): 17 try: 18 # Get the command line arguments of the process 19 cmdline = " ".join(proc.info["cmdline"]) 20 21 # Match the command line with the pattern 22 match = pattern.search(cmdline) 23 if match: 24 config_file = match.group(1) 25 config_files.add(config_file) 26 except (psutil.NoSuchProcess, psutil.AccessDenied): 27 # Process has been terminated or we don't have permission to access it 28 continue 29 30 except Exception as e: 31 logging.error(f"An error occurred: {e}") 32 33 return config_files
Returns names of simulations whose processes are currently running based on the OS.