Commit a21bde9f authored by danduong's avatar danduong Committed by Commit bot

If no device specified, get the first device found

This makes adb_reverse_forwarder.py a little more convenient
to use.

BUG=429859

Review URL: https://codereview.chromium.org/684383004

Cr-Commit-Position: refs/heads/master@{#302548}
parent f2d0aaeb
......@@ -15,6 +15,7 @@ import optparse
import sys
import time
from pylib import android_commands
from pylib import constants, forwarder
from pylib.device import device_utils
from pylib.utils import run_tests_helper
......@@ -50,7 +51,19 @@ def main(argv):
parser.error('Bad port number')
sys.exit(1)
device = device_utils.DeviceUtils(options.device)
devices = android_commands.GetAttachedDevices()
if options.device:
if options.device not in devices:
raise Exception('Error: %s not in attached devices %s' % (options.device,
','.join(devices)))
devices = [options.device]
else:
if not devices:
raise Exception('Error: no connected devices')
print("No device specified. Defaulting to " + devices[0])
device = device_utils.DeviceUtils(devices[0])
constants.SetBuildType(options.build_type)
try:
forwarder.Forwarder.Map(port_pairs, device)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment