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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 self._device_serial = str(device_serial) | 45 self._device_serial = str(device_serial) |
46 | 46 |
47 # pylint: disable=W0613 | 47 # pylint: disable=W0613 |
48 @classmethod | 48 @classmethod |
49 @decorators.WithTimeoutAndRetries | 49 @decorators.WithTimeoutAndRetries |
50 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True): | 50 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True): |
51 cmd = ['adb'] + arg_list | 51 cmd = ['adb'] + arg_list |
52 exit_code, output = cmd_helper.GetCmdStatusAndOutput(cmd) | 52 exit_code, output = cmd_helper.GetCmdStatusAndOutput(cmd) |
53 if exit_code != 0: | 53 if exit_code != 0: |
54 raise device_errors.AdbCommandFailedError( | 54 raise device_errors.AdbCommandFailedError( |
55 cmd, 'returned non-zero exit code %s, output: %s' % | 55 cmd, 'returned non-zero exit code %d and output %r' % |
56 (exit_code, output)) | 56 (exit_code, output)) |
57 # This catches some errors, including when the device drops offline; | 57 # This catches some errors, including when the device drops offline; |
58 # unfortunately adb is very inconsistent with error reporting so many | 58 # unfortunately adb is very inconsistent with error reporting so many |
59 # command failures present differently. | 59 # command failures present differently. |
60 if check_error and output[:len('error:')] == 'error:': | 60 if check_error and output[:len('error:')] == 'error:': |
61 raise device_errors.AdbCommandFailedError(arg_list, output) | 61 raise device_errors.AdbCommandFailedError(arg_list, output) |
62 return output | 62 return output |
63 # pylint: enable=W0613 | 63 # pylint: enable=W0613 |
64 | 64 |
65 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True): | 65 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True): |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 """Restarts the adbd daemon with root permissions, if possible. | 387 """Restarts the adbd daemon with root permissions, if possible. |
388 | 388 |
389 Args: | 389 Args: |
390 timeout: (optional) Timeout per try in seconds. | 390 timeout: (optional) Timeout per try in seconds. |
391 retries: (optional) Number of retries to attempt. | 391 retries: (optional) Number of retries to attempt. |
392 """ | 392 """ |
393 output = self._DeviceAdbCmd(['root'], timeout, retries) | 393 output = self._DeviceAdbCmd(['root'], timeout, retries) |
394 if 'cannot' in output: | 394 if 'cannot' in output: |
395 raise device_errors.AdbCommandFailedError(['root'], output) | 395 raise device_errors.AdbCommandFailedError(['root'], output) |
396 | 396 |
OLD | NEW |