feat(tools): adopt esp-pylib for idf.py logging and errors

Migrate idf.py and its actions to the shared esp-pylib library:
- add esp-pylib (and esp-pylib[ide]) to the core/ide requirements
- base FatalError on esp_pylib.errors.FatalError, keeping the idf.py ctx cleanup
- replace the local raw-ANSI helpers (red_print/yellow_print/print_warning/
  color_print) with esp_pylib.logger.log (warn/err/note/hint) across the
  idf.py actions
- install esp_pylib exception reporting at the idf.py entry point and silence
  the logger during shell completion
- update affected tests for the new prefixes/line wrapping
- add normalize_output() helper and unify terminal env in conftest to handle
  Rich line-wrapping in CI assertions

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Marek Fiala
2026-07-15 20:19:07 +08:00
committed by BOT
co-authored by Cursor
parent 055ba9d3f9
commit 8c08c75f48
25 changed files with 381 additions and 318 deletions
+2 -2
View File
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from esp_pylib.logger import log
from rich_click import Context
from idf_py_actions.errors import FatalError
@@ -8,7 +9,6 @@ from idf_py_actions.tools import PropertyDict
from idf_py_actions.tools import ensure_build_directory
from idf_py_actions.tools import get_sdkconfig_filename
from idf_py_actions.tools import get_sdkconfig_value
from idf_py_actions.tools import red_print
from idf_py_actions.tools import run_target
SOC_USB_DFU_SUPPORTED = 'CONFIG_SOC_USB_DFU_SUPPORTED'
@@ -21,7 +21,7 @@ def action_extensions(base_actions: dict, project_path: str) -> dict:
return True
target = get_sdkconfig_value(sdkconfig_path, 'CONFIG_IDF_TARGET') or 'unknown'
red_print(f'DFU is not supported for this target: {target}')
log.err(f'DFU is not supported for this target: {target}')
return False
def dfu_target(target_name: str, ctx: Context, args: PropertyDict, part_size: str) -> None: