| 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import threading | 7 import threading |
| 8 | 8 |
| 9 from devil.android import device_blacklist | 9 from devil.android import device_blacklist |
| 10 from devil.android import device_errors | 10 from devil.android import device_errors |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 def TearDown(self): | 89 def TearDown(self): |
| 90 # Write the cache even when not using it so that it will be ready the first | 90 # Write the cache even when not using it so that it will be ready the first |
| 91 # time that it is enabled. Writing it every time is also necessary so that | 91 # time that it is enabled. Writing it every time is also necessary so that |
| 92 # an invalid cache can be flushed just by disabling it for one run. | 92 # an invalid cache can be flushed just by disabling it for one run. |
| 93 for d in self._devices: | 93 for d in self._devices: |
| 94 cache_path = _DeviceCachePath(d) | 94 cache_path = _DeviceCachePath(d) |
| 95 with open(cache_path, 'w') as f: | 95 with open(cache_path, 'w') as f: |
| 96 f.write(d.DumpCacheData()) | 96 f.write(d.DumpCacheData()) |
| 97 logging.info('Wrote device cache: %s', cache_path) | 97 logging.info('Wrote device cache: %s', cache_path) |
| 98 | 98 |
| 99 def BlacklistDevice(self, device): | 99 def BlacklistDevice(self, device, reason='local_device_failure'): |
| 100 if not self._blacklist: | 100 if not self._blacklist: |
| 101 logging.warning( | 101 logging.warning( |
| 102 'Attempted to blacklist %s, but no blacklist was provided.', | 102 'Attempted to blacklist %s, but no blacklist was provided.', |
| 103 str(device)) | 103 str(device)) |
| 104 return | 104 return |
| 105 | 105 |
| 106 device_serial = device.adb.GetDeviceSerial() | 106 device_serial = device.adb.GetDeviceSerial() |
| 107 self._blacklist.Extend([device_serial]) | 107 self._blacklist.Extend([device_serial], reason=reason) |
| 108 with self._devices_lock: | 108 with self._devices_lock: |
| 109 self._devices = [d for d in self._devices if str(d) != device_serial] | 109 self._devices = [d for d in self._devices if str(d) != device_serial] |
| 110 | 110 |
| OLD | NEW |