mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 05:34:32 +02:00
Merge branch 'fix/diag_exec_cmd' into 'master'
fix(tools): allow to save stdout and stderr if the exec command fails Closes IDF-12099 See merge request espressif/esp-idf!36626
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
import atexit
|
import atexit
|
||||||
import difflib
|
import difflib
|
||||||
@@ -583,9 +583,10 @@ def cmd_exec(args: Dict, step: Dict, recipe: Dict) -> None:
|
|||||||
|
|
||||||
if p.returncode:
|
if p.returncode:
|
||||||
warn(f'Exec command "{cmd}" failed with exit code {p.returncode}')
|
warn(f'Exec command "{cmd}" failed with exit code {p.returncode}')
|
||||||
return
|
if p.stderr:
|
||||||
|
dbg(f'stderr: "{p.stderr}"')
|
||||||
|
|
||||||
if stdout:
|
if stdout and p.stdout:
|
||||||
try:
|
try:
|
||||||
stdout_path.parent.mkdir(parents=True, exist_ok=True)
|
stdout_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(stdout_path, 'a' if append else 'w') as f:
|
with open(stdout_path, 'a' if append else 'w') as f:
|
||||||
@@ -593,7 +594,7 @@ def cmd_exec(args: Dict, step: Dict, recipe: Dict) -> None:
|
|||||||
except Exception:
|
except Exception:
|
||||||
warn(f'Cannot write exec command "{cmd}" stdout to "{stdout}"')
|
warn(f'Cannot write exec command "{cmd}" stdout to "{stdout}"')
|
||||||
|
|
||||||
if stderr:
|
if stderr and p.stderr:
|
||||||
try:
|
try:
|
||||||
stderr_path.parent.mkdir(parents=True, exist_ok=True)
|
stderr_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(stderr_path, 'a' if append else 'w') as f:
|
with open(stderr_path, 'a' if append else 'w') as f:
|
||||||
|
Reference in New Issue
Block a user