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

Unified Diff: build/android/provision_devices.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 side-by-side diff with in-line comments
Download patch
Index: build/android/provision_devices.py
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py
index 427d1fa91d5330c04bed68c1a79712a68dbf0e07..4466851204f58a57e4340b7f5a4eaf2f8c42436f 100755
--- a/build/android/provision_devices.py
+++ b/build/android/provision_devices.py
@@ -53,27 +53,33 @@ class _PHASES(object):
ALL = [WIPE, PROPERTIES, FINISH]
-def ProvisionDevices(options):
- devices = device_utils.DeviceUtils.HealthyDevices()
- if options.device:
- devices = [d for d in devices if d == options.device]
+def ProvisionDevices(args):
+ if args.blacklist_file:
+ blacklist = device_blacklist.Blacklist(args.blacklist_file)
+ else:
+ # TODO(jbudorick): Remove once the bots have switched over.
+ blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON)
+
+ devices = device_utils.DeviceUtils.HealthyDevices(blacklist)
+ if args.device:
+ devices = [d for d in devices if d == args.device]
if not devices:
- raise device_errors.DeviceUnreachableError(options.device)
+ raise device_errors.DeviceUnreachableError(args.device)
parallel_devices = device_utils.DeviceUtils.parallel(devices)
- parallel_devices.pMap(ProvisionDevice, options)
- if options.auto_reconnect:
+ parallel_devices.pMap(ProvisionDevice, blacklist, args)
+ if args.auto_reconnect:
_LaunchHostHeartbeat()
- blacklist = device_blacklist.ReadBlacklist()
- if options.output_device_blacklist:
- with open(options.output_device_blacklist, 'w') as f:
- json.dump(blacklist, f)
- if all(d in blacklist for d in devices):
+ blacklisted_devices = blacklist.Read()
+ if args.output_device_blacklist:
+ with open(args.output_device_blacklist, 'w') as f:
+ json.dump(blacklisted_devices, f)
+ if all(d in blacklisted_devices for d in devices):
raise device_errors.NoDevicesError
return 0
-def ProvisionDevice(device, options):
+def ProvisionDevice(device, blacklist, options):
if options.reboot_timeout:
reboot_timeout = options.reboot_timeout
elif (device.build_version_sdk >=
@@ -110,12 +116,12 @@ def ProvisionDevice(device, options):
device_errors.CommandTimeoutError):
logging.exception('Timed out waiting for device %s. Adding to blacklist.',
str(device))
- device_blacklist.ExtendBlacklist([str(device)])
+ blacklist.Extend([str(device)])
except device_errors.CommandFailedError:
logging.exception('Failed to provision device %s. Adding to blacklist.',
str(device))
- device_blacklist.ExtendBlacklist([str(device)])
+ blacklist.Extend([str(device)])
def WipeDevice(device, options):
@@ -317,6 +323,7 @@ def main():
parser.add_argument('-d', '--device', metavar='SERIAL',
help='the serial number of the device to be provisioned'
' (the default is to provision all devices attached)')
+ parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
parser.add_argument('--phase', action='append', choices=_PHASES.ALL,
dest='phases',
help='Phases of provisioning to run. '

Powered by Google App Engine
This is Rietveld 408576698