Chromium Code Reviews| Index: build/android/pylib/device/device_utils.py |
| diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py |
| index ea1019d3de996f44b6bcb95785541b7570ee4344..0decda0586dfcc83c35c2a39409785814be95369 100644 |
| --- a/build/android/pylib/device/device_utils.py |
| +++ b/build/android/pylib/device/device_utils.py |
| @@ -9,52 +9,16 @@ Eventually, this will be based on adb_wrapper. |
| """ |
| # pylint: disable=W0613 |
| -import multiprocessing |
| -import os |
| -import sys |
| - |
| import pylib.android_commands |
| from pylib.device import adb_wrapper |
| from pylib.device import decorators |
| from pylib.device import device_errors |
| - |
| -CHROME_SRC_DIR = os.path.abspath( |
| - os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')) |
| -sys.path.append(os.path.join( |
| - CHROME_SRC_DIR, 'third_party', 'android_testrunner')) |
| -import errors |
| +from pylib.utils import parallelizer |
| _DEFAULT_TIMEOUT = 30 |
| _DEFAULT_RETRIES = 3 |
| -# multiprocessing map_async requires a top-level function for pickle library. |
| -def RebootDeviceSafe(device): |
| - """Reboot a device, wait for it to start, and squelch timeout exceptions.""" |
| - try: |
| - DeviceUtils(device).old_interface.Reboot(True) |
| - except errors.DeviceUnresponsiveError as e: |
| - return e |
| - |
| - |
| -def RebootDevices(): |
| - """Reboot all attached and online devices.""" |
| - devices = pylib.android_commands.GetAttachedDevices() |
| - print 'Rebooting: %s' % devices |
| - if devices: |
| - pool = multiprocessing.Pool(len(devices)) |
| - results = pool.map_async(RebootDeviceSafe, devices).get(99999) |
| - |
| - for device, result in zip(devices, results): |
| - if result: |
| - print '%s failed to startup.' % device |
| - |
| - if any(results): |
| - print 'RebootDevices() Warning: %s' % results |
| - else: |
| - print 'Reboots complete.' |
| - |
| - |
| @decorators.WithExplicitTimeoutAndRetries( |
| _DEFAULT_TIMEOUT, _DEFAULT_RETRIES) |
| def GetAVDs(): |
| @@ -150,3 +114,14 @@ class DeviceUtils(object): |
| raise device_errors.CommandFailedError( |
| 'adb root', 'Could not enable root.') |
| + def __str__(self): |
| + return self.old_interface.GetDevice() |
| + |
| + @staticmethod |
| + def parallel(devices): |
|
frankf
2014/05/21 22:34:27
add docstring for this
|
| + if not devices or len(devices) == 0: |
| + devices = pylib.android_commands.AndroidCommands.GetAttachedDevices() |
| + return parallelizer.Parallelizer([ |
| + d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
| + for d in devices]) |
| + |