Chromium Code Reviews| Index: build/android/devil/utils/cmd_helper.py |
| diff --git a/build/android/devil/utils/cmd_helper.py b/build/android/devil/utils/cmd_helper.py |
| index 57e8987558d4a3209c1be35d6f905ed3485cecc4..b0fd23d6552c25a6ffa7e2e546159e47409ce174 100644 |
| --- a/build/android/devil/utils/cmd_helper.py |
| +++ b/build/android/devil/utils/cmd_helper.py |
| @@ -309,3 +309,33 @@ def IterCmdOutputLines(args, timeout=None, cwd=None, shell=False, |
| yield buffer_output |
| if check_status and process.returncode: |
| raise subprocess.CalledProcessError(process.returncode, cmd) |
| + |
| + |
| +def IterCmdOutput(args, timeout=None, cwd=None, shell=False, |
|
mikecase (-- gone --)
2015/12/16 23:52:05
Need the logcat output as soon as I can get it to
|
| + check_status=True): |
| + """Executes a subprocess and continuously yields its output. |
| + |
| + Args: |
| + args: List of arguments to the program, the program to execute is the first |
| + element. |
| + cwd: If not None, the subprocess's current directory will be changed to |
| + |cwd| before it's executed. |
| + shell: Whether to execute args as a shell command. Must be True if args |
| + is a string and False if args is a sequence. |
| + check_status: A boolean indicating whether to check the exit status of the |
| + process after all output has been read. |
| + |
| + Yields: |
| + The output of the subprocess. |
| + |
| + Raises: |
| + CalledProcessError if check_status is True and the process exited with a |
| + non-zero exit status. |
| + """ |
| + cmd = _ValidateAndLogCommand(args, cwd, shell) |
| + process = Popen(args, cwd=cwd, shell=shell, stdout=subprocess.PIPE, |
| + stderr=subprocess.STDOUT) |
| + for data in _IterProcessStdout(process, timeout=timeout): |
| + yield data |
| + if check_status and process.returncode: |
| + raise subprocess.CalledProcessError(process.returncode, cmd) |