Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1660)

Unified Diff: build/android/devil/utils/cmd_helper.py

Issue 1484253003: [Android] Add record functionality to logcat monitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/devil/android/sdk/adb_wrapper.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « build/android/devil/android/sdk/adb_wrapper.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698