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

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

Issue 711113002: Add option to specify ADB binary in test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. 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
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 import errno 11 import errno
12 import os 12 import os
13 13
14 from pylib import cmd_helper 14 from pylib import cmd_helper
15 from pylib import constants
15 from pylib.device import decorators 16 from pylib.device import decorators
16 from pylib.device import device_errors 17 from pylib.device import device_errors
17 from pylib.utils import timeout_retry 18 from pylib.utils import timeout_retry
18 19
19 20
20 _DEFAULT_TIMEOUT = 30 21 _DEFAULT_TIMEOUT = 30
21 _DEFAULT_RETRIES = 2 22 _DEFAULT_RETRIES = 2
22 23
23 24
24 def _VerifyLocalFileExists(path): 25 def _VerifyLocalFileExists(path):
(...skipping 17 matching lines...) Expand all
42 43
43 Args: 44 Args:
44 device_serial: The device serial number as a string. 45 device_serial: The device serial number as a string.
45 """ 46 """
46 self._device_serial = str(device_serial) 47 self._device_serial = str(device_serial)
47 48
48 # pylint: disable=unused-argument 49 # pylint: disable=unused-argument
49 @classmethod 50 @classmethod
50 @decorators.WithTimeoutAndRetries 51 @decorators.WithTimeoutAndRetries
51 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True): 52 def _RunAdbCmd(cls, arg_list, timeout=None, retries=None, check_error=True):
52 cmd = ['adb'] + arg_list 53 cmd = [constants.GetAdbPath()] + arg_list
53 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout( 54 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
54 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime()) 55 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime())
55 if exit_code != 0: 56 if exit_code != 0:
56 raise device_errors.AdbCommandFailedError( 57 raise device_errors.AdbCommandFailedError(
57 cmd, 'returned non-zero exit code %d and output %r' % 58 cmd, 'returned non-zero exit code %d and output %r' %
58 (exit_code, output)) 59 (exit_code, output))
59 # This catches some errors, including when the device drops offline; 60 # This catches some errors, including when the device drops offline;
60 # unfortunately adb is very inconsistent with error reporting so many 61 # unfortunately adb is very inconsistent with error reporting so many
61 # command failures present differently. 62 # command failures present differently.
62 if check_error and output[:len('error:')] == 'error:': 63 if check_error and output[:len('error:')] == 'error:':
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 """Restarts the adbd daemon with root permissions, if possible. 390 """Restarts the adbd daemon with root permissions, if possible.
390 391
391 Args: 392 Args:
392 timeout: (optional) Timeout per try in seconds. 393 timeout: (optional) Timeout per try in seconds.
393 retries: (optional) Number of retries to attempt. 394 retries: (optional) Number of retries to attempt.
394 """ 395 """
395 output = self._DeviceAdbCmd(['root'], timeout, retries) 396 output = self._DeviceAdbCmd(['root'], timeout, retries)
396 if 'cannot' in output: 397 if 'cannot' in output:
397 raise device_errors.AdbCommandFailedError(['root'], output) 398 raise device_errors.AdbCommandFailedError(['root'], output)
398 399
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698