| Index: build/android/pylib/device/adb_wrapper.py
|
| diff --git a/build/android/pylib/device/adb_wrapper.py b/build/android/pylib/device/adb_wrapper.py
|
| index 7d11671212d236fcb9a4d6a7dc738775ef93d29f..f29f5c7689f6505d730fa28cede6a2be6e1e11e7 100644
|
| --- a/build/android/pylib/device/adb_wrapper.py
|
| +++ b/build/android/pylib/device/adb_wrapper.py
|
| @@ -253,6 +253,20 @@ class AdbWrapper(object):
|
| command, output, status=status, device_serial=self._device_serial)
|
| return output
|
|
|
| + def IterShell(self, command, timeout):
|
| + """Runs a shell command and returns an iterator over its output lines.
|
| +
|
| + Args:
|
| + command: A string with the shell command to run.
|
| + timeout: Timeout in seconds.
|
| +
|
| + Yields:
|
| + The output of the command line by line.
|
| + """
|
| + args = ['shell', command]
|
| + return cmd_helper.IterCmdOutputLines(
|
| + self._BuildAdbCmd(args, self._device_serial), timeout=timeout)
|
| +
|
| def Ls(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
|
| """List the contents of a directory on the device.
|
|
|
| @@ -286,26 +300,42 @@ class AdbWrapper(object):
|
| device_serial=self._device_serial)
|
|
|
| def Logcat(self, clear=False, dump=False, filter_spec=None,
|
| - logcat_format=None, timeout=None):
|
| - """Get an iterator over the logcat output.
|
| + logcat_format=None, timeout=None, retries=_DEFAULT_RETRIES):
|
| + """Get an iterable over the logcat output.
|
|
|
| Args:
|
| - filter_spec: (optional) Spec to filter the logcat.
|
| - timeout: (optional) Timeout per try in seconds.
|
| + clear: If true, clear the logcat.
|
| + dump: If true, dump the current logcat contents.
|
| + filter_spec: If set, spec to filter the logcat.
|
| + logcat_format: If set, the format in which the logcat should be output.
|
| + Options include "brief", "process", "tag", "thread", "raw", "time",
|
| + "threadtime", and "long"
|
| + timeout: (optional) If set, timeout per try in seconds. If clear or dump
|
| + is set, defaults to _DEFAULT_TIMEOUT.
|
| + retries: (optional) If clear or dump is set, the number of retries to
|
| + attempt. Otherwise, does nothing.
|
|
|
| Yields:
|
| logcat output line by line.
|
| """
|
| cmd = ['logcat']
|
| + use_iter = True
|
| if clear:
|
| cmd.append('-c')
|
| + use_iter = False
|
| if dump:
|
| cmd.append('-d')
|
| + use_iter = False
|
| if logcat_format:
|
| cmd.extend(['-v', logcat_format])
|
| if filter_spec is not None:
|
| cmd.append(filter_spec)
|
| - return self._IterRunDeviceAdbCmd(cmd, timeout)
|
| +
|
| + if use_iter:
|
| + return self._IterRunDeviceAdbCmd(cmd, timeout)
|
| + else:
|
| + timeout = timeout if timeout is not None else _DEFAULT_TIMEOUT
|
| + return self._RunDeviceAdbCmd(cmd, timeout, retries)
|
|
|
| def Forward(self, local, remote, timeout=_DEFAULT_TIMEOUT,
|
| retries=_DEFAULT_RETRIES):
|
|
|