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

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

Issue 265743002: [Android] Switch to new interfaces of GetAVDs and RestartAdbServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: back to decorators. Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """ 5 """
6 Provides a variety of device interactions based on adb. 6 Provides a variety of device interactions based on adb.
7 7
8 Eventually, this will be based on adb_wrapper. 8 Eventually, this will be based on adb_wrapper.
9 """ 9 """
10 # pylint: disable=W0613
10 11
11 import pylib.android_commands 12 import pylib.android_commands
12 from pylib.device import adb_wrapper 13 from pylib.device import adb_wrapper
14 from pylib.device import decorators
13 15
14 16
15 def GetAVDs(): 17 _DEFAULT_TIMEOUT = 30
18 _DEFAULT_RETRIES = 3
19
20
21 _WithTimeoutAndRetries = decorators.WithTimeoutAndRetries
craigdh 2014/05/13 15:46:24 This additional level of indirection is confusing.
bulach 2014/05/13 16:14:40 gargh! :D ok, rant #271 :) these "translations" ju
craigdh 2014/05/13 16:18:18 I'm 100% with Marcus on this one.
22 _WithTimeoutAndRetriesDefaults = decorators.WithTimeoutAndRetriesDefaults
23 _WithTimeoutAndRetriesFromInstance = (
24 decorators.WithTimeoutAndRetriesFromInstance('_default_timeout',
25 '_default_retries'))
26
27
28 @_WithTimeoutAndRetriesDefaults(_DEFAULT_TIMEOUT, _DEFAULT_RETRIES)
29 def GetAVDs(timeout=None, retries=None):
bulach 2014/05/13 16:14:40 is there any client passing these args in any sens
30 """ Returns a list of Android Virtual Devices.
31
32 Args:
33 timeout: The length of time to wait before giving up on either killing or
34 restarting the server.
35 retries: The number of times to retry either killing or restarting the
36 server.
37 Returns:
38 A list containing the configured AVDs.
39 """
16 return pylib.android_commands.GetAVDs() 40 return pylib.android_commands.GetAVDs()
17 41
18 42
43 @_WithTimeoutAndRetriesDefaults(_DEFAULT_TIMEOUT, _DEFAULT_RETRIES)
44 def RestartServer(timeout=None, retries=None):
45 """ Restarts the adb server.
46
47 Args:
48 timeout: The length of time to wait before giving up on either killing or
49 restarting the server.
50 retries: The number of times to retry either killing or restarting the
51 server.
52 Raises:
53 CommandFailedError if we fail to kill or restart the server.
54 """
55 pylib.android_commands.AndroidCommands().RestartAdbServer()
56
57
19 class DeviceUtils(object): 58 class DeviceUtils(object):
20 59
21 def __init__(self, device): 60 def __init__(self, device):
22 self.old_interface = None 61 self.old_interface = None
23 if isinstance(device, basestring): 62 if isinstance(device, basestring):
24 self.old_interface = pylib.android_commands.AndroidCommands(device) 63 self.old_interface = pylib.android_commands.AndroidCommands(device)
25 elif isinstance(device, adb_wrapper.AdbWrapper): 64 elif isinstance(device, adb_wrapper.AdbWrapper):
26 self.old_interface = pylib.android_commands.AndroidCommands(str(device)) 65 self.old_interface = pylib.android_commands.AndroidCommands(str(device))
27 elif isinstance(device, pylib.android_commands.AndroidCommands): 66 elif isinstance(device, pylib.android_commands.AndroidCommands):
28 self.old_interface = device 67 self.old_interface = device
29 elif not device: 68 elif not device:
30 self.old_interface = pylib.android_commands.AndroidCommands() 69 self.old_interface = pylib.android_commands.AndroidCommands()
31 70
OLDNEW
« no previous file with comments | « build/android/pylib/device/decorators_test.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