Skip to content

Commit

Permalink
Merge branch 'fix/diag_exec_cmd' into 'master'
Browse files Browse the repository at this point in the history
fix(tools): allow to save stdout and stderr if the exec command fails

Closes IDF-12099

See merge request espressif/esp-idf!36626
  • Loading branch information
dobairoland committed Jan 24, 2025
2 parents e65c9a5 + 88c099d commit 3a30e43
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/idf_py_actions/diag_ext.py
Original file line number Diff line number Diff line change
@@ -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
import atexit
import difflib
Expand Down Expand Up @@ -583,17 +583,18 @@ def cmd_exec(args: Dict, step: Dict, recipe: Dict) -> None:

if 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:
stdout_path.parent.mkdir(parents=True, exist_ok=True)
with open(stdout_path, 'a' if append else 'w') as f:
f.write(p.stdout)
except Exception:
warn(f'Cannot write exec command "{cmd}" stdout to "{stdout}"')

if stderr:
if stderr and p.stderr:
try:
stderr_path.parent.mkdir(parents=True, exist_ok=True)
with open(stderr_path, 'a' if append else 'w') as f:
Expand Down

0 comments on commit 3a30e43

Please sign in to comment.