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
3 # found in the LICENSE file.
5 from pylib
.base
import environment
6 from pylib
.device
import adb_wrapper
7 from pylib
.device
import device_errors
8 from pylib
.device
import device_utils
9 from pylib
.utils
import parallelizer
12 class LocalDeviceEnvironment(environment
.Environment
):
14 def __init__(self
, args
, _error_func
):
15 super(LocalDeviceEnvironment
, self
).__init
__()
16 self
._device
_serial
= args
.test_device
18 self
._max
_tries
= 1 + args
.num_retries
19 self
._tool
_name
= args
.tool
23 available_devices
= device_utils
.DeviceUtils
.HealthyDevices()
24 if not available_devices
:
25 raise device_errors
.NoDevicesError
26 if self
._device
_serial
:
27 self
._devices
= [d
for d
in available_devices
28 if d
.adb
.GetDeviceSerial() == self
._device
_serial
]
30 raise device_errors
.DeviceUnreachableError(
31 'Could not find device %r' % self
._device
_serial
)
33 self
._devices
= available_devices
40 def parallel_devices(self
):
41 return parallelizer
.SyncParallelizer(self
._devices
)
45 return self
._max
_tries
49 return self
._tool
_name