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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « build/android/devil/android/sdk/adb_wrapper.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A wrapper for subprocess to make calling shell commands easier.""" 5 """A wrapper for subprocess to make calling shell commands easier."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import pipes 9 import pipes
10 import select 10 import select
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 buffer_output += data 302 buffer_output += data
303 has_incomplete_line = buffer_output[-1] not in '\r\n' 303 has_incomplete_line = buffer_output[-1] not in '\r\n'
304 lines = buffer_output.splitlines() 304 lines = buffer_output.splitlines()
305 buffer_output = lines.pop() if has_incomplete_line else '' 305 buffer_output = lines.pop() if has_incomplete_line else ''
306 for line in lines: 306 for line in lines:
307 yield line 307 yield line
308 if buffer_output: 308 if buffer_output:
309 yield buffer_output 309 yield buffer_output
310 if check_status and process.returncode: 310 if check_status and process.returncode:
311 raise subprocess.CalledProcessError(process.returncode, cmd) 311 raise subprocess.CalledProcessError(process.returncode, cmd)
312
313
314 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
315 check_status=True):
316 """Executes a subprocess and continuously yields its output.
317
318 Args:
319 args: List of arguments to the program, the program to execute is the first
320 element.
321 cwd: If not None, the subprocess's current directory will be changed to
322 |cwd| before it's executed.
323 shell: Whether to execute args as a shell command. Must be True if args
324 is a string and False if args is a sequence.
325 check_status: A boolean indicating whether to check the exit status of the
326 process after all output has been read.
327
328 Yields:
329 The output of the subprocess.
330
331 Raises:
332 CalledProcessError if check_status is True and the process exited with a
333 non-zero exit status.
334 """
335 cmd = _ValidateAndLogCommand(args, cwd, shell)
336 process = Popen(args, cwd=cwd, shell=shell, stdout=subprocess.PIPE,
337 stderr=subprocess.STDOUT)
338 for data in _IterProcessStdout(process, timeout=timeout):
339 yield data
340 if check_status and process.returncode:
341 raise subprocess.CalledProcessError(process.returncode, cmd)
OLDNEW
« 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