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

Unified Diff: build/android/pylib/android_commands.py

Issue 204353007: [Android] Extract device blacklisting into its own module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | build/android/pylib/device/device_blacklist.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index d56a13846036ec16913a2602eb3159358f0e2da8..f000682b70641709bfe193dc6e13ebded47424c8 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -39,6 +39,7 @@ import adb_interface
import am_instrument_parser
import errors
+from pylib.device import device_blacklist
# Pattern to search for the next whole line of pexpect output and capture it
# into a match group. We can't use ^ and $ for line start end with pexpect,
@@ -79,28 +80,23 @@ def GetAVDs():
avds = re_avd.findall(cmd_helper.GetCmdOutput(['android', 'list', 'avd']))
return avds
-
def ResetBadDevices():
- """Removes the file that keeps track of bad devices for a current build."""
- if os.path.exists(constants.BAD_DEVICES_JSON):
- os.remove(constants.BAD_DEVICES_JSON)
-
+ """Removes the blacklist that keeps track of bad devices for a current
+ build.
+ """
+ device_blacklist.ResetBlacklist()
def ExtendBadDevices(devices):
- """Adds devices to BAD_DEVICES_JSON file.
+ """Adds devices to the blacklist that keeps track of bad devices for a
+ current build.
- The devices listed in the BAD_DEVICES_JSON file will not be returned by
+ The devices listed in the bad devices file will not be returned by
GetAttachedDevices.
Args:
- devices: list of bad devices to be added to the BAD_DEVICES_JSON file.
+ devices: list of bad devices to be added to the bad devices file.
"""
- if os.path.exists(constants.BAD_DEVICES_JSON):
- with open(constants.BAD_DEVICES_JSON, 'r') as f:
- bad_devices = json.load(f)
- devices.extend(bad_devices)
- with open(constants.BAD_DEVICES_JSON, 'w') as f:
- json.dump(list(set(devices)), f)
+ device_blacklist.ExtendBlacklist(devices)
def GetAttachedDevices(hardware=True, emulator=True, offline=False):
@@ -150,12 +146,11 @@ def GetAttachedDevices(hardware=True, emulator=True, offline=False):
if offline:
devices = devices + offline_devices
- # Remove bad devices listed in the bad_devices json file.
- if os.path.exists(constants.BAD_DEVICES_JSON):
- with open(constants.BAD_DEVICES_JSON, 'r') as f:
- bad_devices = json.load(f)
- logging.info('Avoiding bad devices %s', ' '.join(bad_devices))
- devices = [device for device in devices if device not in bad_devices]
+ # Remove any devices in the blacklist.
+ blacklist = device_blacklist.ReadBlacklist()
+ if len(blacklist):
+ logging.info('Avoiding bad devices %s', ' '.join(blacklist))
+ devices = [device for device in devices if device not in blacklist]
preferred_device = os.environ.get('ANDROID_SERIAL')
if preferred_device in devices:
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | build/android/pylib/device/device_blacklist.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698