Skip to content

Commit af1f73a

Browse files
authored
Replace stderr writes with logger calls
1 parent d303b4b commit af1f73a

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

platform.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def _setup_python_environment(self, env, platform, platform_dir, should_install=
252252
env.Replace(PYTHONEXE=python_bin)
253253

254254
if not os.path.isfile(python_bin):
255-
sys.stderr.write(f"Python executable not found: {python_bin}\n")
255+
logger.error(f"Python executable not found: {python_bin}")
256256
sys.exit(1)
257257

258258
penv_setup.setup_python_paths(penv_dir)
@@ -262,7 +262,7 @@ def _setup_python_environment(self, env, platform, platform_dir, should_install=
262262

263263
if has_internet_connection() or os.getenv("GITHUB_ACTIONS"):
264264
if not install_dependencies(python_bin, uv_exe):
265-
sys.stderr.write("Failed to install Python dependencies\n")
265+
logger.error("Failed to install Python dependencies")
266266
sys.exit(1)
267267

268268
if should_install:
@@ -276,11 +276,6 @@ def _setup_python_environment(self, env, platform, platform_dir, should_install=
276276

277277
return python_bin, esptool_bin
278278

279-
def setup_python_env(self, env):
280-
if self._penv_python and self._esptool_path:
281-
env.Replace(PYTHONEXE=self._penv_python)
282-
return self._penv_python, self._esptool_path
283-
284279
def _check_tl_install_version(self) -> bool:
285280
"""
286281
Check if tool-esp_install is installed in the correct version.
@@ -817,21 +812,23 @@ def _configure_filesystem_tools(self, variables: Dict, targets: List[str]) -> No
817812
self._install_filesystem_tool(filesystem, for_download=True)
818813

819814
def setup_python_env(self, env):
820-
"""Configure SCons environment with centrally managed Python executable paths."""
821-
if self._penv and self._esptool_path:
822-
env.Replace(PYTHONEXE=self._penv)
823-
return self._penv, self._esptool_path
815+
if self._penv_python and self._esptool_path:
816+
env.Replace(PYTHONEXE=self._penv_python)
817+
return self._penv_python, self._esptool_path
824818

825-
def configure_default_packages(self, variables: Dict, targets: List[str]) -> Any:
819+
def configure_default_packages(self, variables: Dict, targets: List[str]) -> Union[None, Any]:
826820
"""Main configuration method with optimized package management."""
827821
if not variables.get("board"):
828822
return super().configure_default_packages(variables, targets)
829823

830824
core_dir = ProjectConfig.get_instance().get("platformio", "core_dir")
825+
831826
try:
832-
self._penv_python, self._esptool_path = self._setup_python_environment(None, self, core_dir, True)
827+
self._penv_python, self._esptool_path = self._setup_python_environment(
828+
None, self, core_dir, True
829+
)
833830
except Exception as e:
834-
print(f"Python environment setup failed: {e}", file=sys.stderr)
831+
logger.error(f"Python environment setup failed: {e}")
835832

836833
# Base configuration
837834
board_config = self.board_config(variables.get("board"))

0 commit comments

Comments
 (0)