41
41
from platformio .package .manager .tool import ToolPackageManager
42
42
43
43
# Constants
44
- try :
45
- with open ('/proc/device-tree/model' ) as f :
46
- SUBPROCESS_TIMEOUT = 900 if 'raspberry pi' in f .read ().lower () else 300
47
- except :
48
- SUBPROCESS_TIMEOUT = 300
49
- RETRY_LIMIT = 3
50
44
DEFAULT_DEBUG_SPEED = "5000"
51
45
DEFAULT_APP_OFFSET = "0x10000"
52
46
tl_install_name = "tool-esp_install"
91
85
if IS_WINDOWS :
92
86
os .environ ["PLATFORMIO_SYSTEM_TYPE" ] = "windows_amd64"
93
87
88
+ # exit without git
89
+ if not shutil .which ("git" ):
90
+ print ("Git not found in PATH, please install Git." , file = sys .stderr )
91
+ print ("Git is needed for Platform espressif32 to work." , file = sys .stderr )
92
+ raise SystemExit (1 )
93
+
94
94
# Set IDF_TOOLS_PATH to Pio core_dir
95
95
PROJECT_CORE_DIR = ProjectConfig .get_instance ().get ("platformio" , "core_dir" )
96
96
IDF_TOOLS_PATH = os .path .join (PROJECT_CORE_DIR )
97
97
os .environ ["IDF_TOOLS_PATH" ] = IDF_TOOLS_PATH
98
+ os .environ ['IDF_PATH' ] = ""
98
99
99
100
# Global variables
100
101
python_exe = get_pythonexe_path ()
@@ -385,7 +386,11 @@ def _check_tool_status(self, tool_name: str) -> Dict[str, bool]:
385
386
}
386
387
387
388
def _run_idf_tools_install (self , tools_json_path : str , idf_tools_path : str ) -> bool :
388
- """Execute idf_tools.py install command with timeout and error handling."""
389
+ """
390
+ Execute idf_tools.py install command.
391
+ Note: No timeout is set to allow installations to complete on slow networks.
392
+ The tool-esp_install handles the retry logic.
393
+ """
389
394
cmd = [
390
395
python_exe ,
391
396
idf_tools_path ,
@@ -397,11 +402,11 @@ def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> b
397
402
]
398
403
399
404
try :
405
+ logger .info (f"Installing tools via idf_tools.py (this may take several minutes)..." )
400
406
result = subprocess .run (
401
407
cmd ,
402
408
stdout = subprocess .DEVNULL ,
403
409
stderr = subprocess .DEVNULL ,
404
- timeout = SUBPROCESS_TIMEOUT ,
405
410
check = False
406
411
)
407
412
@@ -412,9 +417,6 @@ def _run_idf_tools_install(self, tools_json_path: str, idf_tools_path: str) -> b
412
417
logger .debug ("idf_tools.py executed successfully" )
413
418
return True
414
419
415
- except subprocess .TimeoutExpired :
416
- logger .error (f"Timeout in idf_tools.py after { SUBPROCESS_TIMEOUT } s" )
417
- return False
418
420
except (subprocess .SubprocessError , OSError ) as e :
419
421
logger .error (f"Error in idf_tools.py: { e } " )
420
422
return False
@@ -454,14 +456,8 @@ def _check_tool_version(self, tool_name: str) -> bool:
454
456
logger .error (f"Error reading package data for { tool_name } : { e } " )
455
457
return False
456
458
457
- def install_tool (self , tool_name : str , retry_count : int = 0 ) -> bool :
458
- """Install a tool with optimized retry mechanism."""
459
- if retry_count >= RETRY_LIMIT :
460
- logger .error (
461
- f"Installation of { tool_name } failed after { RETRY_LIMIT } attempts"
462
- )
463
- return False
464
-
459
+ def install_tool (self , tool_name : str ) -> bool :
460
+ """Install a tool."""
465
461
self .packages [tool_name ]["optional" ] = False
466
462
paths = self ._get_tool_paths (tool_name )
467
463
status = self ._check_tool_status (tool_name )
@@ -473,7 +469,7 @@ def install_tool(self, tool_name: str, retry_count: int = 0) -> bool:
473
469
# Case 2: Tool already installed, version check
474
470
if (status ['has_idf_tools' ] and status ['has_piopm' ] and
475
471
not status ['has_tools_json' ]):
476
- return self ._handle_existing_tool (tool_name , paths , retry_count )
472
+ return self ._handle_existing_tool (tool_name , paths )
477
473
478
474
logger .debug (f"Tool { tool_name } already configured" )
479
475
return True
@@ -501,9 +497,7 @@ def _install_with_idf_tools(self, tool_name: str, paths: Dict[str, str]) -> bool
501
497
logger .info (f"Tool { tool_name } successfully installed" )
502
498
return True
503
499
504
- def _handle_existing_tool (
505
- self , tool_name : str , paths : Dict [str , str ], retry_count : int
506
- ) -> bool :
500
+ def _handle_existing_tool (self , tool_name : str , paths : Dict [str , str ]) -> bool :
507
501
"""Handle already installed tools with version checking."""
508
502
if self ._check_tool_version (tool_name ):
509
503
# Version matches, use tool
@@ -518,7 +512,7 @@ def _handle_existing_tool(
518
512
# Remove the main tool directory (if it still exists after cleanup)
519
513
safe_remove_directory (paths ['tool_path' ])
520
514
521
- return self .install_tool (tool_name , retry_count + 1 )
515
+ return self .install_tool (tool_name )
522
516
523
517
def _configure_arduino_framework (self , frameworks : List [str ]) -> None :
524
518
"""Configure Arduino framework dependencies."""
0 commit comments