| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 import datetime | 5 import datetime |
| 6 import functools | 6 import functools |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import tempfile | 10 import tempfile |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 with open(cache_path, 'w') as f: | 181 with open(cache_path, 'w') as f: |
| 182 f.write(d.DumpCacheData()) | 182 f.write(d.DumpCacheData()) |
| 183 logging.info('Wrote device cache: %s', cache_path) | 183 logging.info('Wrote device cache: %s', cache_path) |
| 184 | 184 |
| 185 self.parallel_devices.pMap(tear_down_device) | 185 self.parallel_devices.pMap(tear_down_device) |
| 186 | 186 |
| 187 for m in self._logcat_monitors: | 187 for m in self._logcat_monitors: |
| 188 try: | 188 try: |
| 189 m.Stop() | 189 m.Stop() |
| 190 m.Close() | 190 m.Close() |
| 191 _, temp_path = tempfile.mkstemp() |
| 192 with open(m.output_file, 'r') as infile: |
| 193 with open(temp_path, 'w') as outfile: |
| 194 for line in infile: |
| 195 outfile.write('Device(%s) %s' % (m.adb.GetDeviceSerial(), line)) |
| 196 shutil.move(temp_path, m.output_file) |
| 191 except base_error.BaseError: | 197 except base_error.BaseError: |
| 192 logging.exception('Failed to stop logcat monitor for %s', | 198 logging.exception('Failed to stop logcat monitor for %s', |
| 193 m.adb.GetDeviceSerial()) | 199 m.adb.GetDeviceSerial()) |
| 200 except IOError: |
| 201 logging.exception('Failed to locate logcat for device %s', |
| 202 m.adb.GetDeviceSerial()) |
| 194 | 203 |
| 195 if self._logcat_output_file: | 204 if self._logcat_output_file: |
| 196 file_utils.MergeFiles( | 205 file_utils.MergeFiles( |
| 197 self._logcat_output_file, | 206 self._logcat_output_file, |
| 198 [m.output_file for m in self._logcat_monitors]) | 207 [m.output_file for m in self._logcat_monitors]) |
| 199 shutil.rmtree(self._logcat_output_dir) | 208 shutil.rmtree(self._logcat_output_dir) |
| 200 | 209 |
| 201 def BlacklistDevice(self, device, reason='local_device_failure'): | 210 def BlacklistDevice(self, device, reason='local_device_failure'): |
| 202 device_serial = device.adb.GetDeviceSerial() | 211 device_serial = device.adb.GetDeviceSerial() |
| 203 if self._blacklist: | 212 if self._blacklist: |
| 204 self._blacklist.Extend([device_serial], reason=reason) | 213 self._blacklist.Extend([device_serial], reason=reason) |
| 205 with self._devices_lock: | 214 with self._devices_lock: |
| 206 self._devices = [d for d in self._devices if str(d) != device_serial] | 215 self._devices = [d for d in self._devices if str(d) != device_serial] |
| 207 | 216 |
| OLD | NEW |