Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 1281923003: [Android] Add --blacklist-file as a command-line option. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 self._client_caches[client_name] = {} 1759 self._client_caches[client_name] = {}
1760 return self._client_caches[client_name] 1760 return self._client_caches[client_name]
1761 1761
1762 def _ClearCache(self): 1762 def _ClearCache(self):
1763 """Clears all caches.""" 1763 """Clears all caches."""
1764 for client in self._client_caches: 1764 for client in self._client_caches:
1765 self._client_caches[client].clear() 1765 self._client_caches[client].clear()
1766 self._cache.clear() 1766 self._cache.clear()
1767 1767
1768 @classmethod 1768 @classmethod
1769 def parallel(cls, devices=None, async=False): 1769 def parallel(cls, devices, async=False):
1770 """Creates a Parallelizer to operate over the provided list of devices. 1770 """Creates a Parallelizer to operate over the provided list of devices.
1771 1771
1772 If |devices| is either |None| or an empty list, the Parallelizer will 1772 If |devices| is either |None| or an empty list, the Parallelizer will
1773 operate over all attached devices that have not been blacklisted. 1773 operate over all attached devices that have not been blacklisted.
1774 1774
1775 Args: 1775 Args:
1776 devices: A list of either DeviceUtils instances or objects from 1776 devices: A list of either DeviceUtils instances or objects from
1777 from which DeviceUtils instances can be constructed. If None, 1777 from which DeviceUtils instances can be constructed. If None,
1778 all attached devices will be used. 1778 all attached devices will be used.
1779 async: If true, returns a Parallelizer that runs operations 1779 async: If true, returns a Parallelizer that runs operations
1780 asynchronously. 1780 asynchronously.
1781 1781
1782 Returns: 1782 Returns:
1783 A Parallelizer operating over |devices|. 1783 A Parallelizer operating over |devices|.
1784 """ 1784 """
1785 if not devices: 1785 if not devices:
1786 devices = cls.HealthyDevices() 1786 raise device_errors.NoDevicesError()
1787 if not devices:
1788 raise device_errors.NoDevicesError()
1789 1787
1790 devices = [d if isinstance(d, cls) else cls(d) for d in devices] 1788 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1791 if async: 1789 if async:
1792 return parallelizer.Parallelizer(devices) 1790 return parallelizer.Parallelizer(devices)
1793 else: 1791 else:
1794 return parallelizer.SyncParallelizer(devices) 1792 return parallelizer.SyncParallelizer(devices)
1795 1793
1796 @classmethod 1794 @classmethod
1797 def HealthyDevices(cls): 1795 def HealthyDevices(cls, blacklist=None):
1798 blacklist = device_blacklist.ReadBlacklist() 1796 if not blacklist:
jbudorick 2015/08/13 17:38:17 Ethan: the None blacklist currently gets handled h
1797 # TODO(jbudorick): Remove once clients pass in the blacklist.
1798 blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON)
1799
1800 blacklisted_devices = blacklist.Read()
1799 def blacklisted(adb): 1801 def blacklisted(adb):
1800 if adb.GetDeviceSerial() in blacklist: 1802 if adb.GetDeviceSerial() in blacklisted_devices:
1801 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) 1803 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial())
1802 return True 1804 return True
1803 return False 1805 return False
1804 1806
1805 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1807 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
1806 if not blacklisted(adb)] 1808 if not blacklisted(adb)]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698