blob: d13c1df72c15cf15034adc1029840b5b244a641f [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import logging
import os
import sys
if __name__ == '__main__':
os.path.dirname(__file__), '..', '..', '..')))
from import device_blacklist
from import device_utils
from import fastboot_utils
from import script_common
from devil.constants import exit_codes
from devil.utils import run_tests_helper
logger = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('build_path', help='Path to android build.')
parser.add_argument('-d', '--device', dest='devices', action='append',
help='Device(s) to flash.')
parser.add_argument('-v', '--verbose', default=0, action='count',
help='Verbose level (multiple times for more)')
parser.add_argument('-w', '--wipe', action='store_true',
help='If set, wipes user data')
parser.add_argument('--blacklist-file', help='Device blacklist file.')
args = parser.parse_args()
if args.blacklist_file:
blacklist = device_blacklist.Blacklist(args.blacklist_file).Read()
if blacklist:
logger.critical('Device(s) in blacklist, not flashing devices:')
for key in blacklist:
logger.critical(' %s', key)
return exit_codes.INFRA
flashed_devices = []
failed_devices = []
def flash(device):
fastboot = fastboot_utils.FastbootUtils(device)
fastboot.FlashDevice(args.build_path, wipe=args.wipe)
except Exception: # pylint: disable=broad-except
logger.exception('Device %s failed to flash.', str(device))
devices = script_common.GetDevices(args.devices, args.blacklist_file)
if flashed_devices:'The following devices were flashed:')' %s', ' '.join(str(d) for d in flashed_devices))
if failed_devices:
logger.critical('The following devices failed to flash:')
logger.critical(' %s', ' '.join(str(d) for d in failed_devices))
return exit_codes.INFRA
return 0
if __name__ == '__main__':