OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """This module wraps Android's adb tool. | 5 """This module wraps Android's adb tool. |
6 | 6 |
7 This is a thin wrapper around the adb interface. Any additional complexity | 7 This is a thin wrapper around the adb interface. Any additional complexity |
8 should be delegated to a higher level (ex. DeviceUtils). | 8 should be delegated to a higher level (ex. DeviceUtils). |
9 """ | 9 """ |
10 | 10 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 except ValueError: | 246 except ValueError: |
247 logging.warning('exit status of shell command %r missing.', command) | 247 logging.warning('exit status of shell command %r missing.', command) |
248 raise device_errors.AdbShellCommandFailedError( | 248 raise device_errors.AdbShellCommandFailedError( |
249 command, output, status=None, device_serial=self._device_serial) | 249 command, output, status=None, device_serial=self._device_serial) |
250 output = output[:output_end] | 250 output = output[:output_end] |
251 if status != expect_status: | 251 if status != expect_status: |
252 raise device_errors.AdbShellCommandFailedError( | 252 raise device_errors.AdbShellCommandFailedError( |
253 command, output, status=status, device_serial=self._device_serial) | 253 command, output, status=status, device_serial=self._device_serial) |
254 return output | 254 return output |
255 | 255 |
256 def IterShell(self, command, timeout): | |
jbudorick
2015/02/09 14:21:38
My concern here is that we don't do the same exit
perezju
2015/02/09 16:39:12
We had the same discussion regarding Logcat :)
1.
jbudorick
2015/02/09 16:39:59
Well, at least I'm consistent :)
| |
257 """Runs a shell command and returns an iterator over its output lines. | |
258 | |
259 Args: | |
260 command: A string with the shell command to run. | |
261 timeout: Timeout in seconds. | |
262 | |
263 Yields: | |
264 The output of the command line by line. | |
265 """ | |
266 args = ['shell', command] | |
267 return cmd_helper.IterCmdOutputLines( | |
268 self._BuildAdbCmd(args, self._device_serial), timeout=timeout) | |
269 | |
256 def Ls(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): | 270 def Ls(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES): |
257 """List the contents of a directory on the device. | 271 """List the contents of a directory on the device. |
258 | 272 |
259 Args: | 273 Args: |
260 path: Path on the device filesystem. | 274 path: Path on the device filesystem. |
261 timeout: (optional) Timeout per try in seconds. | 275 timeout: (optional) Timeout per try in seconds. |
262 retries: (optional) Number of retries to attempt. | 276 retries: (optional) Number of retries to attempt. |
263 | 277 |
264 Returns: | 278 Returns: |
265 A list of pairs (filename, stat) for each file found in the directory, | 279 A list of pairs (filename, stat) for each file found in the directory, |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 """Restarts the adbd daemon with root permissions, if possible. | 500 """Restarts the adbd daemon with root permissions, if possible. |
487 | 501 |
488 Args: | 502 Args: |
489 timeout: (optional) Timeout per try in seconds. | 503 timeout: (optional) Timeout per try in seconds. |
490 retries: (optional) Number of retries to attempt. | 504 retries: (optional) Number of retries to attempt. |
491 """ | 505 """ |
492 output = self._RunDeviceAdbCmd(['root'], timeout, retries) | 506 output = self._RunDeviceAdbCmd(['root'], timeout, retries) |
493 if 'cannot' in output: | 507 if 'cannot' in output: |
494 raise device_errors.AdbCommandFailedError( | 508 raise device_errors.AdbCommandFailedError( |
495 ['root'], output, device_serial=self._device_serial) | 509 ['root'], output, device_serial=self._device_serial) |
OLD | NEW |