""" Process Utilities Utilities for detecting and interacting with running processes/applications. """ import psutil from typing import List, Dict def is_process_running(process_name: str) -> bool: """ Check if a process is currently running. Args: process_name: Name of the process (e.g., 'EOS Utility.exe') Returns: bool: True if process is running, False otherwise """ try: for proc in psutil.process_iter(['name']): try: if proc.info['name'] and process_name.lower() in proc.info['name'].lower(): return True except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): pass except Exception as e: print(f"Error checking process {process_name}: {e}") return False def check_camera_applications() -> Dict[str, bool]: """ Check if required camera applications are running. Returns: Dict[str, bool]: Dictionary mapping application name to running status """ # Common process names for camera applications camera_apps = { 'EOS Utility': ['EOS Utility.exe', 'EOSUtility.exe', 'eu.exe'], '2nd Look': ['2ndLook.exe', 'secondlook.exe', '2nd Look.exe'], 'AnalyzIR': ['AnalyzIR.exe', 'analyzir.exe'] } results = {} for app_name, process_names in camera_apps.items(): running = False for proc_name in process_names: if is_process_running(proc_name): running = True break results[app_name] = running return results def get_running_camera_apps() -> List[str]: """ Get list of camera applications that are currently running. Returns: List[str]: List of running camera application names """ status = check_camera_applications() return [app for app, running in status.items() if running] def get_missing_camera_apps() -> List[str]: """ Get list of camera applications that are not running. Returns: List[str]: List of camera application names that are not running """ status = check_camera_applications() return [app for app, running in status.items() if not running]