From f06e7285134f902fbfca9f06b4f967cb991e1403 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 10 Mar 2026 21:48:21 -0600 Subject: [PATCH] refactor: Add LAST_CAST_ADDRESS and streamline subprocess error handling --- main.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/main.py b/main.py index 88bef32..a2c2e9e 100644 --- a/main.py +++ b/main.py @@ -6,8 +6,8 @@ logging.basicConfig( from flask import Flask, request -# Constants AUTO_STOP_TIMEOUT_SECONDS = 3600 # 1 hour +LAST_CAST_ADDRESS = None app = Flask(__name__) auto_stop_timer = None # Timer for automatic VNC stop @@ -63,10 +63,6 @@ def cast_machine(ip_address): # Use Popen to run the command in the background (non-blocking) subprocess.Popen(command, shell=True) logging.info(f"Command '{command}' launched successfully.") - except FileNotFoundError: - # This error is more likely if the shell itself (e.g., /bin/sh) is not found, - # or if 'xtightvncviewer' is not in PATH and the shell fails to find it. - logging.error(f"Failed to launch VNC for {ip_address}: Shell or VNC command might not be found. Ensure xtightvncviewer is in PATH and shell is available.") except Exception as e: # Catch other potential errors during Popen logging.error(f"An error occurred while launching VNC for {ip_address} with Popen: {e}") @@ -87,8 +83,6 @@ def kill_vnc(): if "no process found" in result.stderr.lower(): logging.info("No xtightvncviewer processes were found to kill.") - except FileNotFoundError: - logging.error(f"Command not found: killall. Please ensure it is installed and in PATH.") except Exception as e: logging.error(f"An unexpected error occurred while trying to run killall: {e}")