Skip to content

Commit 634b45e

Browse files
mshinjojhedberg
authored andcommitted
scripts: west_commands: patch: capture subprocess output in apply() method
Pass 'capture_output=True' to the 'subprocess.run()' call in the 'apply()' method. This ensures that stdout and stderr are captured, so 'proc.stderr' is not 'None' when 'self.err()' is called on a failed process. Example without this patch: west patch apply --roll-back error: patch failed: examples/csp_server_client.py:32 error: examples/csp_server_client.py: patch does not apply ERROR: None FATAL ERROR: failed to apply patch libcsp/test.patch Example with this patch: west patch apply --roll-back ERROR: b'error: patch failed: examples/csp_server_client.py:32\n error: examples/csp_server_client.py: patch does not apply\n' FATAL ERROR: failed to apply patch libcsp/test.patch Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
1 parent 5e650e7 commit 634b45e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/west_commands/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def apply(self, args, yml, dst_mods=None):
391391
self.dbg(f"patching {mod}... ", end="")
392392
apply_cmd += patch_path
393393
apply_cmd_list.extend([patch_path])
394-
proc = subprocess.run(apply_cmd_list, cwd=mod_path)
394+
proc = subprocess.run(apply_cmd_list, capture_output=True, cwd=mod_path)
395395
if proc.returncode:
396396
self.dbg("FAIL")
397397
self.err(proc.stderr)

0 commit comments

Comments
 (0)