OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 # pylint: skip-file | 9 # pylint: skip-file |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 """ | 170 """ |
171 adb_devices_output = cmd_helper.GetCmdOutput([constants.GetAdbPath(), | 171 adb_devices_output = cmd_helper.GetCmdOutput([constants.GetAdbPath(), |
172 'devices']) | 172 'devices']) |
173 | 173 |
174 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE) | 174 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE) |
175 online_devices = re_device.findall(adb_devices_output) | 175 online_devices = re_device.findall(adb_devices_output) |
176 | 176 |
177 re_device = re.compile('^(emulator-[0-9]+)\tdevice', re.MULTILINE) | 177 re_device = re.compile('^(emulator-[0-9]+)\tdevice', re.MULTILINE) |
178 emulator_devices = re_device.findall(adb_devices_output) | 178 emulator_devices = re_device.findall(adb_devices_output) |
179 | 179 |
180 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\toffline$', re.MULTILINE) | 180 re_device = re.compile('^([a-zA-Z0-9_:.-]+)\t(?:offline|unauthorized)$', |
| 181 re.MULTILINE) |
181 offline_devices = re_device.findall(adb_devices_output) | 182 offline_devices = re_device.findall(adb_devices_output) |
182 | 183 |
183 devices = [] | 184 devices = [] |
184 # First determine list of online devices (e.g. hardware and/or emulator). | 185 # First determine list of online devices (e.g. hardware and/or emulator). |
185 if hardware and emulator: | 186 if hardware and emulator: |
186 devices = online_devices | 187 devices = online_devices |
187 elif hardware: | 188 elif hardware: |
188 devices = [device for device in online_devices | 189 devices = [device for device in online_devices |
189 if device not in emulator_devices] | 190 if device not in emulator_devices] |
190 elif emulator: | 191 elif emulator: |
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 """ | 1963 """ |
1963 def __init__(self, output): | 1964 def __init__(self, output): |
1964 self._output = output | 1965 self._output = output |
1965 | 1966 |
1966 def write(self, data): | 1967 def write(self, data): |
1967 data = data.replace('\r\r\n', '\n') | 1968 data = data.replace('\r\r\n', '\n') |
1968 self._output.write(data) | 1969 self._output.write(data) |
1969 | 1970 |
1970 def flush(self): | 1971 def flush(self): |
1971 self._output.flush() | 1972 self._output.flush() |
OLD | NEW |