From bdb3a7b12fad7af3dccb8405ab7a12a2fcfafc9f Mon Sep 17 00:00:00 2001 From: GH05TCREW Date: Sat, 17 May 2025 14:13:32 -0600 Subject: [PATCH] Add path search timeout --- configure_mcp.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configure_mcp.py b/configure_mcp.py index 0133e45..272a439 100644 --- a/configure_mcp.py +++ b/configure_mcp.py @@ -1,6 +1,7 @@ import json import os import shutil +import time from pathlib import Path from colorama import init, Fore, Style @@ -107,6 +108,9 @@ MCP_SERVERS = [ def find_executable(exe_name): """Try to find the executable in common installation paths""" + timeout_seconds = 5 + start_time = time.time() + common_paths = [ "C:\\Program Files", "C:\\Program Files (x86)", @@ -119,10 +123,20 @@ def find_executable(exe_name): ] for base_path in common_paths: + # Check if we've exceeded the timeout + if time.time() - start_time > timeout_seconds: + print(f"{Fore.YELLOW}Search timed out after {timeout_seconds} seconds{Style.RESET_ALL}") + return None + if not os.path.exists(base_path): continue for root, dirs, files in os.walk(base_path): + # Check timeout periodically during search + if time.time() - start_time > timeout_seconds: + print(f"{Fore.YELLOW}Search timed out after {timeout_seconds} seconds{Style.RESET_ALL}") + return None + if exe_name in files: return os.path.join(root, exe_name)