OLD | NEW |
| (Empty) |
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. | |
4 | |
5 """Finds devices that can be controlled by telemetry.""" | |
6 | |
7 from telemetry.internal.platform import android_device | |
8 from telemetry.internal.platform import cros_device | |
9 from telemetry.internal.platform import desktop_device | |
10 from telemetry.internal.platform import ios_device | |
11 | |
12 DEVICES = [ | |
13 android_device, | |
14 cros_device, | |
15 desktop_device, | |
16 ios_device, | |
17 ] | |
18 | |
19 | |
20 def _GetAllAvailableDevices(options): | |
21 """Returns a list of all available devices.""" | |
22 devices = [] | |
23 for device in DEVICES: | |
24 devices.extend(device.FindAllAvailableDevices(options)) | |
25 return devices | |
26 | |
27 | |
28 def GetDevicesMatchingOptions(options): | |
29 """Returns a list of devices matching the options.""" | |
30 devices = [] | |
31 if not options.device or options.device == 'list': | |
32 devices = _GetAllAvailableDevices(options) | |
33 elif options.device == 'android': | |
34 devices = android_device.FindAllAvailableDevices(options) | |
35 else: | |
36 devices = _GetAllAvailableDevices(options) | |
37 devices = [d for d in devices if d.guid == options.device] | |
38 | |
39 devices.sort(key=lambda device: device.name) | |
40 return devices | |
OLD | NEW |