OLD | NEW |
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 """ A simple device interface for build steps. | 5 """ A simple device interface for build steps. |
6 | 6 |
7 """ | 7 """ |
8 | 8 |
9 import logging | 9 import logging |
10 import os | 10 import os |
11 import re | 11 import re |
12 import sys | 12 import sys |
13 | 13 |
14 from util import build_utils | 14 from util import build_utils |
15 | 15 |
16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..') | 16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..') |
17 sys.path.append(BUILD_ANDROID_DIR) | 17 sys.path.append(BUILD_ANDROID_DIR) |
18 | 18 |
19 from pylib.device import adb_wrapper | 19 from pylib import android_commands |
20 from pylib.device import device_errors | 20 from pylib.device import device_errors |
21 from pylib.device import device_utils | 21 from pylib.device import device_utils |
22 | 22 |
23 | 23 GetAttachedDevices = android_commands.GetAttachedDevices |
24 def GetAttachedDevices(): | |
25 return [a.GetDeviceSerial() | |
26 for a in adb_wrapper.Devices()] | |
27 | 24 |
28 | 25 |
29 class BuildDevice(object): | 26 class BuildDevice(object): |
30 def __init__(self, configuration): | 27 def __init__(self, configuration): |
31 self.id = configuration['id'] | 28 self.id = configuration['id'] |
32 self.description = configuration['description'] | 29 self.description = configuration['description'] |
33 self.install_metadata = configuration['install_metadata'] | 30 self.install_metadata = configuration['install_metadata'] |
34 self.device = device_utils.DeviceUtils(self.id) | 31 self.device = device_utils.DeviceUtils(self.id) |
35 | 32 |
36 def RunShellCommand(self, *args, **kwargs): | 33 def RunShellCommand(self, *args, **kwargs): |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 assert len(configurations) == 1 | 99 assert len(configurations) == 1 |
103 return BuildDevice(configurations[0]) | 100 return BuildDevice(configurations[0]) |
104 | 101 |
105 | 102 |
106 def GetBuildDeviceFromPath(path): | 103 def GetBuildDeviceFromPath(path): |
107 configurations = ReadConfigurations(path) | 104 configurations = ReadConfigurations(path) |
108 if len(configurations) > 0: | 105 if len(configurations) > 0: |
109 return GetBuildDevice(ReadConfigurations(path)) | 106 return GetBuildDevice(ReadConfigurations(path)) |
110 return None | 107 return None |
111 | 108 |
OLD | NEW |