summaryrefslogtreecommitdiff
path: root/tools/patman
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2021-10-20 14:24:09 -0400
committerTom Rini <[email protected]>2021-10-20 14:24:09 -0400
commit79b8849d4c1e73df2a79a1d5a5f6166d0dd67a12 (patch)
treeb630c9a63287d8586b85f2bdd00af56353c66b25 /tools/patman
parent11c41192ec08ba6ded60b0d6e8257cfbd6ad1914 (diff)
parentf0045799c6957e374cc12a6146ac60881cd827d6 (diff)
Merge tag 'u-boot-imx-20211020' of https://source.denx.de/u-boot/custodians/u-boot-imx
u-boot-imx-20211020 ------------------- First PR from u-boot-imx for 2022.01 CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/9535 - new board: kontron-sl-mx8mm - imx8m: - fix secure boot - imx ESDHC: fixes - i.MX53: Support thum2, bmode and fixes for Menlo board usbarmory switch to Ethernet driver model - imx6 : - DDR calibration for Toradex boards - imx7: - Fixes - Updated gateworks boards (ventana / venice) # gpg verification failed.
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/command.py7
-rw-r--r--tools/patman/cros_subprocess.py10
2 files changed, 13 insertions, 4 deletions
diff --git a/tools/patman/command.py b/tools/patman/command.py
index bf8ea6c8c3c..d54b1e0efce 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -49,7 +49,8 @@ test_result = None
def RunPipe(pipe_list, infile=None, outfile=None,
capture=False, capture_stderr=False, oneline=False,
- raise_on_error=True, cwd=None, binary=False, **kwargs):
+ raise_on_error=True, cwd=None, binary=False,
+ output_func=None, **kwargs):
"""
Perform a command pipeline, with optional input/output filenames.
@@ -63,6 +64,8 @@ def RunPipe(pipe_list, infile=None, outfile=None,
capture: True to capture output
capture_stderr: True to capture stderr
oneline: True to strip newline chars from output
+ output_func: Output function to call with each output fragment
+ (if it returns True the function terminates)
kwargs: Additional keyword arguments to cros_subprocess.Popen()
Returns:
CommandResult object
@@ -105,7 +108,7 @@ def RunPipe(pipe_list, infile=None, outfile=None,
if capture:
result.stdout, result.stderr, result.combined = (
- last_pipe.CommunicateFilter(None))
+ last_pipe.CommunicateFilter(output_func))
if result.stdout and oneline:
result.output = result.stdout.rstrip(b'\r\n')
result.return_code = last_pipe.wait()
diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py
index fdd51386856..88a4693feff 100644
--- a/tools/patman/cros_subprocess.py
+++ b/tools/patman/cros_subprocess.py
@@ -128,6 +128,9 @@ class Popen(subprocess.Popen):
sys.stdout or sys.stderr.
data: a string containing the data
+ Returns:
+ True to terminate the process
+
Note: The data read is buffered in memory, so do not use this
method if the data size is large or unlimited.
@@ -175,6 +178,7 @@ class Popen(subprocess.Popen):
stderr = bytearray()
combined = bytearray()
+ stop_now = False
input_offset = 0
while read_set or write_set:
try:
@@ -212,7 +216,7 @@ class Popen(subprocess.Popen):
stdout += data
combined += data
if output:
- output(sys.stdout, data)
+ stop_now = output(sys.stdout, data)
if self.stderr in rlist:
data = b''
# We will get an error on read if the pty is closed
@@ -227,7 +231,9 @@ class Popen(subprocess.Popen):
stderr += data
combined += data
if output:
- output(sys.stderr, data)
+ stop_now = output(sys.stderr, data)
+ if stop_now:
+ self.terminate()
# All data exchanged. Translate lists into strings.
stdout = self.ConvertData(stdout)