Use the new DeviceUtils.HealthyDevices(device_arg=) in a few scripts
BUG=none Review URL: https://codereview.chromium.org/1895163002 Cr-Original-Commit-Position: refs/heads/master@{#387991} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: bb574a0099d40f6ce916fd5a2dd2118dbbce7a36
This commit is contained in:
Родитель
798b172f15
Коммит
8de09d6a0b
|
@ -24,8 +24,8 @@ Empty string: Deletes command-line file.
|
|||
Otherwise: Writes command-line file.
|
||||
|
||||
'''
|
||||
parser.add_argument('-d', '--device', dest='device',
|
||||
help='Target device for apk to install on.')
|
||||
parser.add_argument('-d', '--device', dest='devices', action='append',
|
||||
default=[], help='Target device serial (repeatable).')
|
||||
parser.add_argument('--device-path', required=True,
|
||||
help='Remote path to flags file.')
|
||||
parser.add_argument('-e', '--executable', dest='executable', default='chrome',
|
||||
|
@ -36,13 +36,8 @@ Otherwise: Writes command-line file.
|
|||
|
||||
as_root = not args.device_path.startswith('/data/local/tmp/')
|
||||
|
||||
if args.device:
|
||||
devices = [device_utils.DeviceUtils(args.device, default_retries=0)]
|
||||
else:
|
||||
devices = device_utils.DeviceUtils.HealthyDevices(default_retries=0)
|
||||
if not devices:
|
||||
raise device_errors.NoDevicesError()
|
||||
|
||||
devices = device_utils.DeviceUtils.HealthyDevices(device_arg=args.devices,
|
||||
default_retries=0)
|
||||
all_devices = device_utils.DeviceUtils.parallel(devices)
|
||||
|
||||
def print_args():
|
||||
|
|
|
@ -54,6 +54,7 @@ def main():
|
|||
help='If set, run test suites under out/Release. '
|
||||
'Default is env var BUILDTYPE or Debug.')
|
||||
parser.add_argument('-d', '--device', dest='devices', action='append',
|
||||
default=[],
|
||||
help='Target device for apk to install on. Enter multiple'
|
||||
' times for multiple devices.')
|
||||
parser.add_argument('--adb-path',
|
||||
|
@ -109,14 +110,8 @@ def main():
|
|||
blacklist = (device_blacklist.Blacklist(args.blacklist_file)
|
||||
if args.blacklist_file
|
||||
else None)
|
||||
devices = device_utils.DeviceUtils.HealthyDevices(blacklist)
|
||||
|
||||
if args.devices:
|
||||
devices = [d for d in devices if d in args.devices]
|
||||
if not devices:
|
||||
raise device_errors.DeviceUnreachableError(args.devices)
|
||||
elif not devices:
|
||||
raise device_errors.NoDevicesError()
|
||||
devices = device_utils.DeviceUtils.HealthyDevices(blacklist=blacklist,
|
||||
device_arg=args.devices)
|
||||
|
||||
def blacklisting_install(device):
|
||||
try:
|
||||
|
|
|
@ -11,7 +11,6 @@ i.e., "adb forward" in reverse. Requires |host_forwarder| and |device_forwarder|
|
|||
to be built.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import optparse
|
||||
import sys
|
||||
import time
|
||||
|
@ -19,7 +18,6 @@ import time
|
|||
import devil_chromium
|
||||
|
||||
from devil.android import device_blacklist
|
||||
from devil.android import device_errors
|
||||
from devil.android import device_utils
|
||||
from devil.android import forwarder
|
||||
from devil.utils import run_tests_helper
|
||||
|
@ -63,18 +61,8 @@ def main(argv):
|
|||
blacklist = (device_blacklist.Blacklist(options.blacklist_file)
|
||||
if options.blacklist_file
|
||||
else None)
|
||||
devices = device_utils.DeviceUtils.HealthyDevices(blacklist)
|
||||
|
||||
if options.device:
|
||||
device = next((d for d in devices if d == options.device), None)
|
||||
if not device:
|
||||
raise device_errors.DeviceUnreachableError(options.device)
|
||||
elif devices:
|
||||
device = devices[0]
|
||||
logging.info('No device specified. Defaulting to %s', devices[0])
|
||||
else:
|
||||
raise device_errors.NoDevicesError()
|
||||
|
||||
device = device_utils.DeviceUtils.HealthyDevices(blacklist=blacklist,
|
||||
device_arg=options.device)
|
||||
constants.SetBuildType(options.build_type)
|
||||
try:
|
||||
forwarder.Forwarder.Map(port_pairs, device)
|
||||
|
|
|
@ -286,27 +286,12 @@ def main():
|
|||
logging.fatal(args.dont_even_try)
|
||||
return 1
|
||||
|
||||
if args.device:
|
||||
# Retries are annoying when commands fail for legitimate reasons. Might want
|
||||
# to enable them if this is ever used on bots though.
|
||||
device = device_utils.DeviceUtils(
|
||||
args.device, default_retries=0, enable_device_files_cache=True)
|
||||
else:
|
||||
devices = device_utils.DeviceUtils.HealthyDevices(
|
||||
default_retries=0, enable_device_files_cache=True)
|
||||
if not devices:
|
||||
raise device_errors.NoDevicesError()
|
||||
elif len(devices) == 1:
|
||||
device = devices[0]
|
||||
else:
|
||||
all_devices = device_utils.DeviceUtils.parallel(devices)
|
||||
msg = ('More than one device available.\n'
|
||||
'Use --device=SERIAL to select a device.\n'
|
||||
'Available devices:\n')
|
||||
descriptions = all_devices.pMap(lambda d: d.build_description).pGet(None)
|
||||
for d, desc in zip(devices, descriptions):
|
||||
msg += ' %s (%s)\n' % (d, desc)
|
||||
raise Exception(msg)
|
||||
# Retries are annoying when commands fail for legitimate reasons. Might want
|
||||
# to enable them if this is ever used on bots though.
|
||||
device = device_utils.DeviceUtils.HealthyDevices(
|
||||
device_arg=args.device,
|
||||
default_retries=0,
|
||||
enable_device_files_cache=True)[0]
|
||||
|
||||
apk = apk_helper.ToHelper(args.apk_path)
|
||||
if args.uninstall:
|
||||
|
|
Загрузка…
Ссылка в новой задаче