| OLD | NEW | 
|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python | 
| 2 # | 2 # | 
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be | 
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. | 
| 6 | 6 | 
| 7 """Provisions Android devices with settings required for bots. | 7 """Provisions Android devices with settings required for bots. | 
| 8 | 8 | 
| 9 Usage: | 9 Usage: | 
| 10   ./provision_devices.py [-d <device serial number>] | 10   ./provision_devices.py [-d <device serial number>] | 
| 11 """ | 11 """ | 
| 12 | 12 | 
| 13 import argparse | 13 import argparse | 
| 14 import logging | 14 import logging | 
| 15 import os | 15 import os | 
| 16 import posixpath | 16 import posixpath | 
| 17 import re | 17 import re | 
| 18 import subprocess | 18 import subprocess | 
| 19 import sys | 19 import sys | 
| 20 import time | 20 import time | 
| 21 | 21 | 
| 22 from pylib import constants | 22 from pylib import constants | 
| 23 from pylib import device_settings | 23 from pylib import device_settings | 
| 24 from pylib.device import adb_wrapper |  | 
| 25 from pylib.device import battery_utils | 24 from pylib.device import battery_utils | 
| 26 from pylib.device import device_blacklist | 25 from pylib.device import device_blacklist | 
| 27 from pylib.device import device_errors | 26 from pylib.device import device_errors | 
| 28 from pylib.device import device_filter |  | 
| 29 from pylib.device import device_utils | 27 from pylib.device import device_utils | 
| 30 from pylib.utils import run_tests_helper | 28 from pylib.utils import run_tests_helper | 
| 31 from pylib.utils import timeout_retry | 29 from pylib.utils import timeout_retry | 
| 32 | 30 | 
| 33 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, | 31 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, | 
| 34                              'third_party', 'android_testrunner')) | 32                              'third_party', 'android_testrunner')) | 
| 35 import errors | 33 import errors | 
| 36 | 34 | 
| 37 | 35 | 
| 38 class _DEFAULT_TIMEOUTS(object): | 36 class _DEFAULT_TIMEOUTS(object): | 
| 39   # L can take a while to reboot after a wipe. | 37   # L can take a while to reboot after a wipe. | 
| 40   LOLLIPOP = 600 | 38   LOLLIPOP = 600 | 
| 41   PRE_LOLLIPOP = 180 | 39   PRE_LOLLIPOP = 180 | 
| 42 | 40 | 
| 43   HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) | 41   HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) | 
| 44 | 42 | 
| 45 | 43 | 
| 46 class _PHASES(object): | 44 class _PHASES(object): | 
| 47   WIPE = 'wipe' | 45   WIPE = 'wipe' | 
| 48   PROPERTIES = 'properties' | 46   PROPERTIES = 'properties' | 
| 49   FINISH = 'finish' | 47   FINISH = 'finish' | 
| 50 | 48 | 
| 51   ALL = [WIPE, PROPERTIES, FINISH] | 49   ALL = [WIPE, PROPERTIES, FINISH] | 
| 52 | 50 | 
| 53 | 51 | 
| 54 def ProvisionDevices(options): | 52 def ProvisionDevices(options): | 
| 55   if options.device is not None: | 53   if options.device is not None: | 
| 56     devices = [options.device] | 54     devices = [options.device] | 
| 57   else: | 55   else: | 
| 58     devices = adb_wrapper.AdbWrapper.Devices( | 56     devices = device_utils.DeviceUtils.HealthyDevices() | 
| 59         filters=device_filter.DefaultFilters()) |  | 
| 60 | 57 | 
| 61   parallel_devices = device_utils.DeviceUtils.parallel(devices) | 58   parallel_devices = device_utils.DeviceUtils.parallel(devices) | 
| 62   parallel_devices.pMap(ProvisionDevice, options) | 59   parallel_devices.pMap(ProvisionDevice, options) | 
| 63   if options.auto_reconnect: | 60   if options.auto_reconnect: | 
| 64     _LaunchHostHeartbeat() | 61     _LaunchHostHeartbeat() | 
| 65   blacklist = device_blacklist.ReadBlacklist() | 62   blacklist = device_blacklist.ReadBlacklist() | 
| 66   if all(d in blacklist for d in devices): | 63   if all(d in blacklist for d in devices): | 
| 67     raise device_errors.NoDevicesError | 64     raise device_errors.NoDevicesError | 
| 68   return 0 | 65   return 0 | 
| 69 | 66 | 
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 314   args = parser.parse_args() | 311   args = parser.parse_args() | 
| 315   constants.SetBuildType(args.target) | 312   constants.SetBuildType(args.target) | 
| 316 | 313 | 
| 317   run_tests_helper.SetLogLevel(args.verbose) | 314   run_tests_helper.SetLogLevel(args.verbose) | 
| 318 | 315 | 
| 319   return ProvisionDevices(args) | 316   return ProvisionDevices(args) | 
| 320 | 317 | 
| 321 | 318 | 
| 322 if __name__ == '__main__': | 319 if __name__ == '__main__': | 
| 323   sys.exit(main()) | 320   sys.exit(main()) | 
| OLD | NEW | 
|---|