| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 |expect_rc|. | 169 |expect_rc|. |
| 170 """ | 170 """ |
| 171 if expect_rc is None: | 171 if expect_rc is None: |
| 172 actual_command = command | 172 actual_command = command |
| 173 else: | 173 else: |
| 174 actual_command = '%s; echo $?;' % command | 174 actual_command = '%s; echo $?;' % command |
| 175 output = self._DeviceAdbCmd( | 175 output = self._DeviceAdbCmd( |
| 176 ['shell', actual_command], timeout, retries, check_error=False) | 176 ['shell', actual_command], timeout, retries, check_error=False) |
| 177 if expect_rc is not None: | 177 if expect_rc is not None: |
| 178 output_end = output.rstrip().rfind('\n') + 1 | 178 output_end = output.rstrip().rfind('\n') + 1 |
| 179 rc = int(output[output_end:].strip()) | 179 rc = output[output_end:].strip() |
| 180 output = output[:output_end] | 180 output = output[:output_end] |
| 181 if rc != expect_rc: | 181 if int(rc) != expect_rc: |
| 182 raise device_errors.AdbShellCommandFailedError( | 182 raise device_errors.AdbCommandFailedError( |
| 183 command, rc, output, self._device_serial) | 183 ['shell', command], |
| 184 'shell command exited with code: %s' % rc, |
| 185 self._device_serial) |
| 184 return output | 186 return output |
| 185 | 187 |
| 186 def Logcat(self, filter_spec=None, timeout=_DEFAULT_TIMEOUT, | 188 def Logcat(self, filter_spec=None, timeout=_DEFAULT_TIMEOUT, |
| 187 retries=_DEFAULT_RETRIES): | 189 retries=_DEFAULT_RETRIES): |
| 188 """Get the logcat output. | 190 """Get the logcat output. |
| 189 | 191 |
| 190 Args: | 192 Args: |
| 191 filter_spec: (optional) Spec to filter the logcat. | 193 filter_spec: (optional) Spec to filter the logcat. |
| 192 timeout: (optional) Timeout per try in seconds. | 194 timeout: (optional) Timeout per try in seconds. |
| 193 retries: (optional) Number of retries to attempt. | 195 retries: (optional) Number of retries to attempt. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 """Restarts the adbd daemon with root permissions, if possible. | 378 """Restarts the adbd daemon with root permissions, if possible. |
| 377 | 379 |
| 378 Args: | 380 Args: |
| 379 timeout: (optional) Timeout per try in seconds. | 381 timeout: (optional) Timeout per try in seconds. |
| 380 retries: (optional) Number of retries to attempt. | 382 retries: (optional) Number of retries to attempt. |
| 381 """ | 383 """ |
| 382 output = self._DeviceAdbCmd(['root'], timeout, retries) | 384 output = self._DeviceAdbCmd(['root'], timeout, retries) |
| 383 if 'cannot' in output: | 385 if 'cannot' in output: |
| 384 raise device_errors.AdbCommandFailedError(['root'], output) | 386 raise device_errors.AdbCommandFailedError(['root'], output) |
| 385 | 387 |
| OLD | NEW |