Skip to content

Commit 6f9391d

Browse files
authored
Refactor tool installation by removing timeout and retries (#276)
* Refactor tool installation by removing timeout and retries * Update docstring for _run_idf_tools_install method
1 parent 1970373 commit 6f9391d

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

platform.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@
4343
from platformio.package.manager.tool import ToolPackageManager
4444

4545
# Constants
46-
try:
47-
with open('/proc/device-tree/model') as f:
48-
SUBPROCESS_TIMEOUT = 900 if 'raspberry pi' in f.read().lower() else 300
49-
except:
50-
SUBPROCESS_TIMEOUT = 300
51-
RETRY_LIMIT = 3
5246
DEFAULT_DEBUG_SPEED = "5000"
5347
DEFAULT_APP_OFFSET = "0x10000"
5448
tl_install_name = "tool-esp_install"
@@ -402,7 +396,11 @@ def _check_tool_status(self, tool_name: str) -> Dict[str, bool]:
402396
}
403397

404398
def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> bool:
405-
"""Execute idf_tools.py install command with timeout and error handling."""
399+
"""
400+
Execute idf_tools.py install command.
401+
Note: No timeout is set to allow installations to complete on slow networks.
402+
The tool-esp_install handles the retry logic.
403+
"""
406404
cmd = [
407405
python_exe,
408406
idf_tools_path,
@@ -414,11 +412,11 @@ def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> b
414412
]
415413

416414
try:
415+
logger.info(f"Installing tools via idf_tools.py (this may take several minutes)...")
417416
result = subprocess.run(
418417
cmd,
419418
stdout=subprocess.DEVNULL,
420419
stderr=subprocess.DEVNULL,
421-
timeout=SUBPROCESS_TIMEOUT,
422420
check=False
423421
)
424422

@@ -429,9 +427,6 @@ def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> b
429427
logger.debug("idf_tools.py executed successfully")
430428
return True
431429

432-
except subprocess.TimeoutExpired:
433-
logger.error(f"Timeout in idf_tools.py after {SUBPROCESS_TIMEOUT}s")
434-
return False
435430
except (subprocess.SubprocessError, OSError) as e:
436431
logger.error(f"Error in idf_tools.py: {e}")
437432
return False
@@ -471,14 +466,8 @@ def _check_tool_version(self, tool_name: str) -> bool:
471466
logger.error(f"Error reading package data for {tool_name}: {e}")
472467
return False
473468

474-
def install_tool(self, tool_name: str, retry_count: int = 0) -> bool:
475-
"""Install a tool with optimized retry mechanism."""
476-
if retry_count >= RETRY_LIMIT:
477-
logger.error(
478-
f"Installation of {tool_name} failed after {RETRY_LIMIT} attempts"
479-
)
480-
return False
481-
469+
def install_tool(self, tool_name: str) -> bool:
470+
"""Install a tool."""
482471
self.packages[tool_name]["optional"] = False
483472
paths = self._get_tool_paths(tool_name)
484473
status = self._check_tool_status(tool_name)
@@ -490,7 +479,7 @@ def install_tool(self, tool_name: str, retry_count: int = 0) -> bool:
490479
# Case 2: Tool already installed, version check
491480
if (status['has_idf_tools'] and status['has_piopm'] and
492481
not status['has_tools_json']):
493-
return self._handle_existing_tool(tool_name, paths, retry_count)
482+
return self._handle_existing_tool(tool_name, paths)
494483

495484
logger.debug(f"Tool {tool_name} already configured")
496485
return True
@@ -518,9 +507,7 @@ def _install_with_idf_tools(self, tool_name: str, paths: Dict[str, str]) -> bool
518507
logger.info(f"Tool {tool_name} successfully installed")
519508
return True
520509

521-
def _handle_existing_tool(
522-
self, tool_name: str, paths: Dict[str, str], retry_count: int
523-
) -> bool:
510+
def _handle_existing_tool(self, tool_name: str, paths: Dict[str, str]) -> bool:
524511
"""Handle already installed tools with version checking."""
525512
if self._check_tool_version(tool_name):
526513
# Version matches, use tool
@@ -535,7 +522,7 @@ def _handle_existing_tool(
535522
# Remove the main tool directory (if it still exists after cleanup)
536523
safe_remove_directory(paths['tool_path'])
537524

538-
return self.install_tool(tool_name, retry_count + 1)
525+
return self.install_tool(tool_name)
539526

540527
def _configure_arduino_framework(self, frameworks: List[str]) -> None:
541528
"""Configure Arduino framework dependencies."""

0 commit comments

Comments
 (0)