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 logging | 6 import logging |
7 import os | 7 import os |
8 import threading | 8 import threading |
9 | 9 |
10 from devil.android import device_blacklist | 10 from devil.android import device_blacklist |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 else: | 54 else: |
55 self._devices = available_devices | 55 self._devices = available_devices |
56 | 56 |
57 if self._enable_device_cache: | 57 if self._enable_device_cache: |
58 for d in self._devices: | 58 for d in self._devices: |
59 cache_path = _DeviceCachePath(d) | 59 cache_path = _DeviceCachePath(d) |
60 if os.path.exists(cache_path): | 60 if os.path.exists(cache_path): |
61 logging.info('Using device cache: %s', cache_path) | 61 logging.info('Using device cache: %s', cache_path) |
62 with open(cache_path) as f: | 62 with open(cache_path) as f: |
63 d.LoadCacheData(f.read()) | 63 d.LoadCacheData(f.read()) |
| 64 # Delete cached file so that any exceptions cause it to be cleared. |
64 os.unlink(cache_path) | 65 os.unlink(cache_path) |
65 if self._logcat_output_dir: | 66 if self._logcat_output_dir: |
66 for d in self._devices: | 67 for d in self._devices: |
67 logcat_file = os.path.join( | 68 logcat_file = os.path.join( |
68 self._logcat_output_dir, | 69 self._logcat_output_dir, |
69 '%s_%s' % (d.adb.GetDeviceSerial(), | 70 '%s_%s' % (d.adb.GetDeviceSerial(), |
70 datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%S'))) | 71 datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%S'))) |
71 monitor = logcat_monitor.LogcatMonitor( | 72 monitor = logcat_monitor.LogcatMonitor( |
72 d.adb, clear=True, output_file=logcat_file) | 73 d.adb, clear=True, output_file=logcat_file) |
73 self._logcat_monitors.append(monitor) | 74 self._logcat_monitors.append(monitor) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 m.Stop() | 114 m.Stop() |
114 m.Close() | 115 m.Close() |
115 | 116 |
116 def BlacklistDevice(self, device, reason='local_device_failure'): | 117 def BlacklistDevice(self, device, reason='local_device_failure'): |
117 device_serial = device.adb.GetDeviceSerial() | 118 device_serial = device.adb.GetDeviceSerial() |
118 if self._blacklist: | 119 if self._blacklist: |
119 self._blacklist.Extend([device_serial], reason=reason) | 120 self._blacklist.Extend([device_serial], reason=reason) |
120 with self._devices_lock: | 121 with self._devices_lock: |
121 self._devices = [d for d in self._devices if str(d) != device_serial] | 122 self._devices = [d for d in self._devices if str(d) != device_serial] |
122 | 123 |
OLD | NEW |