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

Side by Side Diff: build/android/pylib/device/adb_wrapper.py

Issue 727543003: [Android] Fix new pylint errors in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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
OLDNEW
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 27 matching lines...) Expand all
38 """A wrapper around a local Android Debug Bridge executable.""" 38 """A wrapper around a local Android Debug Bridge executable."""
39 39
40 def __init__(self, device_serial): 40 def __init__(self, device_serial):
41 """Initializes the AdbWrapper. 41 """Initializes the AdbWrapper.
42 42
43 Args: 43 Args:
44 device_serial: The device serial number as a string. 44 device_serial: The device serial number as a string.
45 """ 45 """
46 self._device_serial = str(device_serial) 46 self._device_serial = str(device_serial)
47 47
48 # pylint: disable=W0613 48 # pylint: disable=unused-argument
49 @classmethod 49 @classmethod
50 @decorators.WithTimeoutAndRetries 50 @decorators.WithTimeoutAndRetries
51 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True): 51 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True):
52 cmd = ['adb'] + arg_list 52 cmd = ['adb'] + arg_list
53 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( 53 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
54 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime()) 54 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime())
55 if exit_code != 0: 55 if exit_code != 0:
56 raise device_errors.AdbCommandFailedError( 56 raise device_errors.AdbCommandFailedError(
57 cmd, 'returned non-zero exit code %d and output %r' % 57 cmd, 'returned non-zero exit code %d and output %r' %
58 (exit_code, output)) 58 (exit_code, output))
59 # This catches some errors, including when the device drops offline; 59 # This catches some errors, including when the device drops offline;
60 # unfortunately adb is very inconsistent with error reporting so many 60 # unfortunately adb is very inconsistent with error reporting so many
61 # command failures present differently. 61 # command failures present differently.
62 if check_error and output[:len('error:')] == 'error:': 62 if check_error and output[:len('error:')] == 'error:':
63 raise device_errors.AdbCommandFailedError(arg_list, output) 63 raise device_errors.AdbCommandFailedError(arg_list, output)
64 return output 64 return output
65 # pylint: enable=W0613 65 # pylint: enable=unused-argument
66 66
67 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True): 67 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True):
68 """Runs an adb command on the device associated with this object. 68 """Runs an adb command on the device associated with this object.
69 69
70 Args: 70 Args:
71 arg_list: A list of arguments to adb. 71 arg_list: A list of arguments to adb.
72 timeout: Timeout in seconds. 72 timeout: Timeout in seconds.
73 retries: Number of retries. 73 retries: Number of retries.
74 check_error: Check that the command doesn't return an error message. This 74 check_error: Check that the command doesn't return an error message. This
75 does NOT check the return code of shell commands. 75 does NOT check the return code of shell commands.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 """Restarts the adbd daemon with root permissions, if possible. 389 """Restarts the adbd daemon with root permissions, if possible.
390 390
391 Args: 391 Args:
392 timeout: (optional) Timeout per try in seconds. 392 timeout: (optional) Timeout per try in seconds.
393 retries: (optional) Number of retries to attempt. 393 retries: (optional) Number of retries to attempt.
394 """ 394 """
395 output = self._DeviceAdbCmd(['root'], timeout, retries) 395 output = self._DeviceAdbCmd(['root'], timeout, retries)
396 if 'cannot' in output: 396 if 'cannot' in output:
397 raise device_errors.AdbCommandFailedError(['root'], output) 397 raise device_errors.AdbCommandFailedError(['root'], output)
398 398
OLDNEW
« no previous file with comments | « build/android/pylib/base/base_test_result.py ('k') | build/android/pylib/device/decorators_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698