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

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

Issue 221823011: [Android] Change object types from AndroidCommands to DeviceUtils in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Frank's comments. Created 6 years, 8 months 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 21 matching lines...) Expand all
32 super(CommandFailedError, self).__init__( 32 super(CommandFailedError, self).__init__(
33 (('device %s: ' % device) if device else '') + 33 (('device %s: ' % device) if device else '') +
34 'adb command \'%s\' failed with message: \'%s\'' % (' '.join(cmd), msg)) 34 'adb command \'%s\' failed with message: \'%s\'' % (' '.join(cmd), msg))
35 35
36 36
37 class CommandTimeoutError(BaseError): 37 class CommandTimeoutError(BaseError):
38 """Exception for command timeouts.""" 38 """Exception for command timeouts."""
39 pass 39 pass
40 40
41 41
42 class DeviceUnreachableError(BaseError):
43 """Exception for device unreachable failures."""
44 pass
45
42 def _VerifyLocalFileExists(path): 46 def _VerifyLocalFileExists(path):
43 """Verifies a local file exists. 47 """Verifies a local file exists.
44 48
45 Args: 49 Args:
46 path: Path to the local file. 50 path: Path to the local file.
47 51
48 Raises: 52 Raises:
49 IOError: If the file doesn't exist. 53 IOError: If the file doesn't exist.
50 """ 54 """
51 if not os.path.exists(path): 55 if not os.path.exists(path):
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 Args: 149 Args:
146 timeout: (optional) Timeout per try in seconds. 150 timeout: (optional) Timeout per try in seconds.
147 retries: (optional) Number of retries to attempt. 151 retries: (optional) Number of retries to attempt.
148 152
149 Yields: 153 Yields:
150 AdbWrapper instances. 154 AdbWrapper instances.
151 """ 155 """
152 output = cls._AdbCmd(['devices'], timeout, retries) 156 output = cls._AdbCmd(['devices'], timeout, retries)
153 lines = [line.split() for line in output.split('\n')] 157 lines = [line.split() for line in output.split('\n')]
154 return [AdbWrapper(line[0]) for line in lines 158 return [AdbWrapper(line[0]) for line in lines
155 if len(line) == 2 and line[1] == 'device'] 159 if len(line) == 2 and line[1] == 'device']
156 160
157 def GetDeviceSerial(self): 161 def GetDeviceSerial(self):
158 """Gets the device serial number associated with this object. 162 """Gets the device serial number associated with this object.
159 163
160 Returns: 164 Returns:
161 Device serial number as a string. 165 Device serial number as a string.
162 """ 166 """
163 return self._device_serial 167 return self._device_serial
164 168
165 def Push(self, local, remote, timeout=60*5, retries=_DEFAULT_RETRIES): 169 def Push(self, local, remote, timeout=60*5, retries=_DEFAULT_RETRIES):
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 """Restarts the adbd daemon with root permissions, if possible. 417 """Restarts the adbd daemon with root permissions, if possible.
414 418
415 Args: 419 Args:
416 timeout: (optional) Timeout per try in seconds. 420 timeout: (optional) Timeout per try in seconds.
417 retries: (optional) Number of retries to attempt. 421 retries: (optional) Number of retries to attempt.
418 """ 422 """
419 output = self._DeviceAdbCmd(['root'], timeout, retries) 423 output = self._DeviceAdbCmd(['root'], timeout, retries)
420 if 'cannot' in output: 424 if 'cannot' in output:
421 raise CommandFailedError(['root'], output) 425 raise CommandFailedError(['root'], output)
422 426
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698