Chromium Code Reviews| 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 |
| 11 import threading | 11 import threading |
| 12 import fileinput | |
|
ghost stip (do not use)
2016/07/29 21:56:40
nit: sort all system imports
nicholaslin
2016/07/29 23:54:06
Done.
| |
| 13 import sys | |
| 12 | 14 |
| 13 from devil import base_error | 15 from devil import base_error |
| 14 from devil.android import device_blacklist | 16 from devil.android import device_blacklist |
| 15 from devil.android import device_errors | 17 from devil.android import device_errors |
| 16 from devil.android import device_list | 18 from devil.android import device_list |
| 17 from devil.android import device_utils | 19 from devil.android import device_utils |
| 18 from devil.android import logcat_monitor | 20 from devil.android import logcat_monitor |
| 19 from devil.utils import file_utils | 21 from devil.utils import file_utils |
| 20 from devil.utils import parallelizer | 22 from devil.utils import parallelizer |
| 21 from pylib import constants | 23 from pylib import constants |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 with open(cache_path, 'w') as f: | 183 with open(cache_path, 'w') as f: |
| 182 f.write(d.DumpCacheData()) | 184 f.write(d.DumpCacheData()) |
| 183 logging.info('Wrote device cache: %s', cache_path) | 185 logging.info('Wrote device cache: %s', cache_path) |
| 184 | 186 |
| 185 self.parallel_devices.pMap(tear_down_device) | 187 self.parallel_devices.pMap(tear_down_device) |
| 186 | 188 |
| 187 for m in self._logcat_monitors: | 189 for m in self._logcat_monitors: |
| 188 try: | 190 try: |
| 189 m.Stop() | 191 m.Stop() |
| 190 m.Close() | 192 m.Close() |
| 193 for line in fileinput.input([m.output_file], inplace=True): | |
|
ghost stip (do not use)
2016/07/29 21:56:39
cool! didn't know about fileinput
| |
| 194 sys.stdout.write('Device(%s) %s' % (m.adb.GetDeviceSerial(), line)) | |
|
ghost stip (do not use)
2016/07/29 21:56:40
does stdout work here? that is surprising
nicholaslin
2016/07/29 23:54:06
From the local testing I did, yes. inplace=true mo
| |
| 191 except base_error.BaseError: | 195 except base_error.BaseError: |
| 192 logging.exception('Failed to stop logcat monitor for %s', | 196 logging.exception('Failed to stop logcat monitor for %s', |
| 193 m.adb.GetDeviceSerial()) | 197 m.adb.GetDeviceSerial()) |
| 194 | 198 |
| 195 if self._logcat_output_file: | 199 if self._logcat_output_file: |
| 196 file_utils.MergeFiles( | 200 file_utils.MergeFiles( |
| 197 self._logcat_output_file, | 201 self._logcat_output_file, |
| 198 [m.output_file for m in self._logcat_monitors]) | 202 [m.output_file for m in self._logcat_monitors]) |
| 199 shutil.rmtree(self._logcat_output_dir) | 203 shutil.rmtree(self._logcat_output_dir) |
| 200 | 204 |
| 201 def BlacklistDevice(self, device, reason='local_device_failure'): | 205 def BlacklistDevice(self, device, reason='local_device_failure'): |
| 202 device_serial = device.adb.GetDeviceSerial() | 206 device_serial = device.adb.GetDeviceSerial() |
| 203 if self._blacklist: | 207 if self._blacklist: |
| 204 self._blacklist.Extend([device_serial], reason=reason) | 208 self._blacklist.Extend([device_serial], reason=reason) |
| 205 with self._devices_lock: | 209 with self._devices_lock: |
| 206 self._devices = [d for d in self._devices if str(d) != device_serial] | 210 self._devices = [d for d in self._devices if str(d) != device_serial] |
| 207 | 211 |
| OLD | NEW |