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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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/native_app_dependencies.gypi ('k') | build/android/pylib/device/device_utils.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.device import decorators 15 from pylib.device import decorators
16 from pylib.device import device_errors 16 from pylib.device import device_errors
17 from pylib.utils import timeout_retry
17 18
18 19
19 _DEFAULT_TIMEOUT = 30 20 _DEFAULT_TIMEOUT = 30
20 _DEFAULT_RETRIES = 2 21 _DEFAULT_RETRIES = 2
21 22
22 23
23 def _VerifyLocalFileExists(path): 24 def _VerifyLocalFileExists(path):
24 """Verifies a local file exists. 25 """Verifies a local file exists.
25 26
26 Args: 27 Args:
(...skipping 15 matching lines...) Expand all
42 Args: 43 Args:
43 device_serial: The device serial number as a string. 44 device_serial: The device serial number as a string.
44 """ 45 """
45 self._device_serial = str(device_serial) 46 self._device_serial = str(device_serial)
46 47
47 # pylint: disable=W0613 48 # pylint: disable=W0613
48 @classmethod 49 @classmethod
49 @decorators.WithTimeoutAndRetries 50 @decorators.WithTimeoutAndRetries
50 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):
51 cmd = ['adb'] + arg_list 52 cmd = ['adb'] + arg_list
52 exit_code, output = cmd_helper.GetCmdStatusAndOutput(cmd) 53 exit_code, output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
54 cmd, timeout_retry.CurrentTimeoutThread().GetRemainingTime())
53 if exit_code != 0: 55 if exit_code != 0:
54 raise device_errors.AdbCommandFailedError( 56 raise device_errors.AdbCommandFailedError(
55 cmd, 'returned non-zero exit code %s, output: %s' % 57 cmd, 'returned non-zero exit code %d and output %r' %
56 (exit_code, output)) 58 (exit_code, output))
57 # This catches some errors, including when the device drops offline; 59 # This catches some errors, including when the device drops offline;
58 # unfortunately adb is very inconsistent with error reporting so many 60 # unfortunately adb is very inconsistent with error reporting so many
59 # command failures present differently. 61 # command failures present differently.
60 if check_error and output[:len('error:')] == 'error:': 62 if check_error and output[:len('error:')] == 'error:':
61 raise device_errors.AdbCommandFailedError(arg_list, output) 63 raise device_errors.AdbCommandFailedError(arg_list, output)
62 return output 64 return output
63 # pylint: enable=W0613 65 # pylint: enable=W0613
64 66
65 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True): 67 def _DeviceAdbCmd(self, arg_list, timeout, retries, check_error=True):
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 """Restarts the adbd daemon with root permissions, if possible. 389 """Restarts the adbd daemon with root permissions, if possible.
388 390
389 Args: 391 Args:
390 timeout: (optional) Timeout per try in seconds. 392 timeout: (optional) Timeout per try in seconds.
391 retries: (optional) Number of retries to attempt. 393 retries: (optional) Number of retries to attempt.
392 """ 394 """
393 output = self._DeviceAdbCmd(['root'], timeout, retries) 395 output = self._DeviceAdbCmd(['root'], timeout, retries)
394 if 'cannot' in output: 396 if 'cannot' in output:
395 raise device_errors.AdbCommandFailedError(['root'], output) 397 raise device_errors.AdbCommandFailedError(['root'], output)
396 398
OLDNEW
« no previous file with comments | « build/android/native_app_dependencies.gypi ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698