Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
from platformio.package.manager.tool import ToolPackageManager

# Constants
try:
with open('/proc/device-tree/model') as f:
SUBPROCESS_TIMEOUT = 900 if 'raspberry pi' in f.read().lower() else 300
except:
SUBPROCESS_TIMEOUT = 300
RETRY_LIMIT = 3
DEFAULT_DEBUG_SPEED = "5000"
DEFAULT_APP_OFFSET = "0x10000"
tl_install_name = "tool-esp_install"
Expand Down Expand Up @@ -402,7 +396,11 @@ def _check_tool_status(self, tool_name: str) -> Dict[str, bool]:
}

def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> bool:
"""Execute idf_tools.py install command with timeout and error handling."""
"""
Execute idf_tools.py install command.
Note: No timeout is set to allow installations to complete on slow networks.
The tool-esp_install handles the retry logic.
"""
cmd = [
python_exe,
idf_tools_path,
Expand All @@ -414,11 +412,11 @@ def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> b
]

try:
logger.info(f"Installing tools via idf_tools.py (this may take several minutes)...")
result = subprocess.run(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=SUBPROCESS_TIMEOUT,
check=False
)

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

except subprocess.TimeoutExpired:
logger.error(f"Timeout in idf_tools.py after {SUBPROCESS_TIMEOUT}s")
return False
except (subprocess.SubprocessError, OSError) as e:
logger.error(f"Error in idf_tools.py: {e}")
return False
Expand Down Expand Up @@ -471,14 +466,8 @@ def _check_tool_version(self, tool_name: str) -> bool:
logger.error(f"Error reading package data for {tool_name}: {e}")
return False

def install_tool(self, tool_name: str, retry_count: int = 0) -> bool:
"""Install a tool with optimized retry mechanism."""
if retry_count >= RETRY_LIMIT:
logger.error(
f"Installation of {tool_name} failed after {RETRY_LIMIT} attempts"
)
return False

def install_tool(self, tool_name: str) -> bool:
"""Install a tool."""
self.packages[tool_name]["optional"] = False
paths = self._get_tool_paths(tool_name)
status = self._check_tool_status(tool_name)
Expand All @@ -490,7 +479,7 @@ def install_tool(self, tool_name: str, retry_count: int = 0) -> bool:
# Case 2: Tool already installed, version check
if (status['has_idf_tools'] and status['has_piopm'] and
not status['has_tools_json']):
return self._handle_existing_tool(tool_name, paths, retry_count)
return self._handle_existing_tool(tool_name, paths)

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

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

return self.install_tool(tool_name, retry_count + 1)
return self.install_tool(tool_name)

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