Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/browser_options.py

Issue 10915114: chrome_remote_control: Fix osx browser discovery (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Tweaks Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/chrome_remote_control/chrome_remote_control/desktop_browser_backend.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import optparse 4 import optparse
5 import sys 5 import sys
6 import shlex
6 7
7 import browser_finder 8 import browser_finder
8 9
9 class BrowserOptions(optparse.Values): 10 class BrowserOptions(optparse.Values):
10 """Options to be used for disocvering and launching browsers.""" 11 """Options to be used for disocvering and launching browsers."""
11 12
12 def __init__(self): 13 def __init__(self):
13 optparse.Values.__init__(self) 14 optparse.Values.__init__(self)
14 self.dont_override_profile = False 15 self.dont_override_profile = False
15 self.hide_stdout = True 16 self.show_stdout = False
16 self.browser_executable = None 17 self.browser_executable = None
17 self._browser_type = None 18 self._browser_type = None
18 self.chrome_root = None 19 self.chrome_root = None
19 self.android_device = None 20 self.android_device = None
20 self.extra_browser_args = [] 21 self.extra_browser_args = []
21 22
22 def CreateParser(self, *args, **kwargs): 23 def CreateParser(self, *args, **kwargs):
23 parser = optparse.OptionParser(*args, **kwargs) 24 parser = optparse.OptionParser(*args, **kwargs)
24 parser.add_option('--browser', 25 parser.add_option('--browser',
25 dest='browser_type', 26 dest='browser_type',
26 default=None, 27 default=None,
27 help='Browser type to run, ' 28 help='Browser type to run, '
28 'in order of priority. Supported values: list,%s' % 29 'in order of priority. Supported values: list,%s' %
29 browser_finder.ALL_BROWSER_TYPES) 30 browser_finder.ALL_BROWSER_TYPES)
30 parser.add_option('--dont-override-profile', action='store_true', 31 parser.add_option('--dont-override-profile', action='store_true',
31 dest='dont_override_profile', 32 dest='dont_override_profile',
32 help='Uses the regular user profile instead of a clean one') 33 help='Uses the regular user profile instead of a clean one')
33 parser.add_option('--browser-executable', 34 parser.add_option('--browser-executable',
34 dest='browser_executable', 35 dest='browser_executable',
35 help='The exact browser to run.') 36 help='The exact browser to run.')
36 parser.add_option('--chrome-root', 37 parser.add_option('--chrome-root',
37 dest='chrome_root', 38 dest='chrome_root',
38 help='Where to look for chrome builds.' 39 help='Where to look for chrome builds.'
39 'Defaults to searching parent dirs by default.') 40 'Defaults to searching parent dirs by default.')
41 parser.add_option('--extra-browser-args',
42 dest='extra_browser_args_as_string',
43 help='Additional arguments to pass to the browser when it starts')
44 parser.add_option('--show-stdout',
45 action='store_true',
46 help="When possible, will display the stdout of the process")
40 parser.add_option('--device', 47 parser.add_option('--device',
41 dest='android_device', 48 dest='android_device',
42 help='The android device ID to use' 49 help='The android device ID to use'
43 'If not specified, only 0 or 1 connected devcies are supported.') 50 'If not specified, only 0 or 1 connected devcies are supported.')
44 real_parse = parser.parse_args 51 real_parse = parser.parse_args
45 def ParseArgs(args=None): 52 def ParseArgs(args=None):
46 defaults = parser.get_default_values() 53 defaults = parser.get_default_values()
47 for k, v in defaults.__dict__.items(): 54 for k, v in defaults.__dict__.items():
48 if k in self.__dict__: 55 if k in self.__dict__:
49 continue 56 continue
50 self.__dict__[k] = v 57 self.__dict__[k] = v
51 ret = real_parse(args, self) 58 ret = real_parse(args, self)
52 if self.browser_executable and not self.browser_type: 59 if self.browser_executable and not self.browser_type:
53 self.browser_type = 'exact' 60 self.browser_type = 'exact'
54 if not self.browser_executable and not self.browser_type: 61 if not self.browser_executable and not self.browser_type:
55 sys.stderr.write("Must provide --browser=<type>\n") 62 sys.stderr.write("Must provide --browser=<type>\n")
56 sys.exit(1) 63 sys.exit(1)
57 if self.browser_type == 'list': 64 if self.browser_type == 'list':
58 import browser_finder 65 import browser_finder
59 types = browser_finder.GetAllAvailableBrowserTypes(self) 66 types = browser_finder.GetAllAvailableBrowserTypes(self)
60 sys.stderr.write("Available browsers:\n"); 67 sys.stderr.write("Available browsers:\n");
61 sys.stdout.write(" %s\n" % "\n ".join(types)) 68 sys.stdout.write(" %s\n" % "\n ".join(types))
62 sys.exit(1) 69 sys.exit(1)
70 if self.extra_browser_args_as_string:
71 tmp = shlex.split(self.extra_browser_args_as_string)
72 self.extra_browser_args.extend(tmp)
73 delattr(self, 'extra_browser_args_as_string')
63 return ret 74 return ret
64 parser.parse_args = ParseArgs 75 parser.parse_args = ParseArgs
65 return parser 76 return parser
66 77
67 @property 78 @property
68 def browser_types_to_use(self): 79 def browser_types_to_use(self):
69 return self._browser_types_to_use 80 return self._browser_types_to_use
70 81
71 @browser_types_to_use.setter 82 @browser_types_to_use.setter
72 def browser_types_to_use(self, value): 83 def browser_types_to_use(self, value):
73 self._browser_types_to_use = value.split(',') 84 self._browser_types_to_use = value.split(',')
74 85
75 """ 86 """
76 This global variable can be set to a BrowserOptions object by the test harness 87 This global variable can be set to a BrowserOptions object by the test harness
77 to allow multiple unit tests to use a specific browser, in face of multiple 88 to allow multiple unit tests to use a specific browser, in face of multiple
78 options. 89 options.
79 """ 90 """
80 options_for_unittests = None 91 options_for_unittests = None
OLDNEW
« no previous file with comments | « no previous file | tools/chrome_remote_control/chrome_remote_control/desktop_browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698