Index: tools/telemetry/telemetry/core/browser_options.py |
diff --git a/tools/telemetry/telemetry/core/browser_options.py b/tools/telemetry/telemetry/core/browser_options.py |
index 43e5793c6bc1bc7611d5b281d336cc746db3fa7a..3a790386b9c4e28572056c23827a8b186a4541f5 100644 |
--- a/tools/telemetry/telemetry/core/browser_options.py |
+++ b/tools/telemetry/telemetry/core/browser_options.py |
@@ -12,6 +12,7 @@ import sys |
from telemetry.core import browser_finder |
from telemetry.core import browser_finder_exceptions |
+from telemetry.core import device_finder |
from telemetry.core import platform |
from telemetry.core import profile_types |
from telemetry.core import util |
@@ -32,7 +33,7 @@ class BrowserFinderOptions(optparse.Values): |
self.browser_type = browser_type |
self.browser_executable = None |
self.chrome_root = None |
- self.android_device = None |
+ self.device = None |
self.cros_ssh_identity = None |
self.extensions_to_load = [] |
@@ -76,8 +77,8 @@ class BrowserFinderOptions(optparse.Values): |
help='Where to look for chrome builds.' |
'Defaults to searching parent dirs by default.') |
group.add_option('--device', |
- dest='android_device', |
- help='The android device ID to use' |
+ dest='device', |
+ help='The device ID to use.' |
'If not specified, only 0 or 1 connected devices are supported.') |
group.add_option('--target-arch', |
dest='target_arch', |
@@ -159,16 +160,40 @@ class BrowserFinderOptions(optparse.Values): |
else: |
logging.getLogger().setLevel(logging.WARNING) |
+ if self.device == 'list': |
+ devices = device_finder.GetAllAvailableDeviceNames(self) |
+ print 'Available devices:' |
+ for device in devices: |
+ print ' ', device |
+ sys.exit(0) |
+ |
if self.browser_executable and not self.browser_type: |
self.browser_type = 'exact' |
if self.browser_type == 'list': |
- try: |
- types = browser_finder.GetAllAvailableBrowserTypes(self) |
- except browser_finder_exceptions.BrowserFinderException, ex: |
- sys.stderr.write('ERROR: ' + str(ex)) |
- sys.exit(1) |
- sys.stdout.write('Available browsers:\n') |
- sys.stdout.write(' %s\n' % '\n '.join(types)) |
+ devices = [] |
+ if self.device and self.device != 'list': |
+ devices = device_finder.GetSpecifiedDevices(self) |
+ else: |
+ devices = device_finder.GetAllAvailableDevices(self) |
+ if not devices: |
+ sys.exit(0) |
+ browser_types = {} |
+ for device in devices: |
+ try: |
+ possible_browsers = browser_finder.GetAllAvailableBrowsers(self, |
+ device) |
+ browser_types[device.name] = sorted( |
+ [browser.browser_type for browser in possible_browsers]) |
+ except browser_finder_exceptions.BrowserFinderException as ex: |
+ print >> sys.stderr, 'ERROR: ', ex |
+ sys.exit(1) |
+ print 'Available browsers:' |
+ if len(browser_types) == 0: |
+ print ' No devices were found.' |
+ for device_name in sorted(browser_types.keys()): |
+ print ' ', device_name |
+ for browser_type in browser_types[device_name]: |
+ print ' ', browser_type |
sys.exit(0) |
# Parse browser options. |