| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 self._blacklist, enable_device_files_cache=self._enable_device_cache, | 114 self._blacklist, enable_device_files_cache=self._enable_device_cache, |
| 115 default_retries=self._max_tries - 1, device_arg=device_arg) | 115 default_retries=self._max_tries - 1, device_arg=device_arg) |
| 116 if not self._devices: | 116 if not self._devices: |
| 117 raise device_errors.NoDevicesError | 117 raise device_errors.NoDevicesError |
| 118 | 118 |
| 119 if self._logcat_output_file: | 119 if self._logcat_output_file: |
| 120 self._logcat_output_dir = tempfile.mkdtemp() | 120 self._logcat_output_dir = tempfile.mkdtemp() |
| 121 | 121 |
| 122 @handle_shard_failures_with(on_failure=self.BlacklistDevice) | 122 @handle_shard_failures_with(on_failure=self.BlacklistDevice) |
| 123 def prepare_device(d): | 123 def prepare_device(d): |
| 124 d.WaitUntilFullyBooted(timeout=10, retries=0) |
| 125 |
| 124 if self._enable_device_cache: | 126 if self._enable_device_cache: |
| 125 cache_path = _DeviceCachePath(d) | 127 cache_path = _DeviceCachePath(d) |
| 126 if os.path.exists(cache_path): | 128 if os.path.exists(cache_path): |
| 127 logging.info('Using device cache: %s', cache_path) | 129 logging.info('Using device cache: %s', cache_path) |
| 128 with open(cache_path) as f: | 130 with open(cache_path) as f: |
| 129 d.LoadCacheData(f.read()) | 131 d.LoadCacheData(f.read()) |
| 130 # Delete cached file so that any exceptions cause it to be cleared. | 132 # Delete cached file so that any exceptions cause it to be cleared. |
| 131 os.unlink(cache_path) | 133 os.unlink(cache_path) |
| 132 | 134 |
| 133 if self._logcat_output_dir: | 135 if self._logcat_output_dir: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if os.path.exists(m.output_file)]) | 224 if os.path.exists(m.output_file)]) |
| 223 shutil.rmtree(self._logcat_output_dir) | 225 shutil.rmtree(self._logcat_output_dir) |
| 224 | 226 |
| 225 def BlacklistDevice(self, device, reason='local_device_failure'): | 227 def BlacklistDevice(self, device, reason='local_device_failure'): |
| 226 device_serial = device.adb.GetDeviceSerial() | 228 device_serial = device.adb.GetDeviceSerial() |
| 227 if self._blacklist: | 229 if self._blacklist: |
| 228 self._blacklist.Extend([device_serial], reason=reason) | 230 self._blacklist.Extend([device_serial], reason=reason) |
| 229 with self._devices_lock: | 231 with self._devices_lock: |
| 230 self._devices = [d for d in self._devices if str(d) != device_serial] | 232 self._devices = [d for d in self._devices if str(d) != device_serial] |
| 231 | 233 |
| OLD | NEW |