OLD | NEW |
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 os as os | 4 import os as os |
5 import sys as sys | 5 import sys as sys |
6 import subprocess as subprocess | 6 import subprocess as subprocess |
7 import shutil | 7 import shutil |
8 import tempfile | 8 import tempfile |
9 | 9 |
10 import browser_backend | 10 import browser_backend |
(...skipping 21 matching lines...) Expand all Loading... |
32 raise Exception("Cannot create browser, no executable found!") | 32 raise Exception("Cannot create browser, no executable found!") |
33 | 33 |
34 self._port = DEFAULT_PORT | 34 self._port = DEFAULT_PORT |
35 args = [self._executable, | 35 args = [self._executable, |
36 "--no-first-run", | 36 "--no-first-run", |
37 "--remote-debugging-port=%i" % self._port] | 37 "--remote-debugging-port=%i" % self._port] |
38 if not options.dont_override_profile: | 38 if not options.dont_override_profile: |
39 self._tmpdir = tempfile.mkdtemp() | 39 self._tmpdir = tempfile.mkdtemp() |
40 args.append("--user-data-dir=%s" % self._tmpdir) | 40 args.append("--user-data-dir=%s" % self._tmpdir) |
41 args.extend(options.extra_browser_args) | 41 args.extend(options.extra_browser_args) |
42 if options.hide_stdout: | 42 if not options.show_stdout: |
43 self._devnull = open(os.devnull, 'w') | 43 self._devnull = open(os.devnull, 'w') |
44 self._proc = subprocess.Popen( | 44 self._proc = subprocess.Popen( |
45 args,stdout=self._devnull, stderr=self._devnull) | 45 args,stdout=self._devnull, stderr=self._devnull) |
46 else: | 46 else: |
47 self._devnull = None | 47 self._devnull = None |
48 self._proc = subprocess.Popen(args) | 48 self._proc = subprocess.Popen(args) |
49 | 49 |
50 try: | 50 try: |
51 self._WaitForBrowserToComeUp() | 51 self._WaitForBrowserToComeUp() |
52 except: | 52 except: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 self._proc = None | 85 self._proc = None |
86 raise Exception("Could not shutdown the browser.") | 86 raise Exception("Could not shutdown the browser.") |
87 | 87 |
88 if self._tmpdir and os.path.exists(self._tmpdir): | 88 if self._tmpdir and os.path.exists(self._tmpdir): |
89 shutil.rmtree(self._tmpdir, ignore_errors=True) | 89 shutil.rmtree(self._tmpdir, ignore_errors=True) |
90 self._tmpdir = None | 90 self._tmpdir = None |
91 | 91 |
92 if self._devnull: | 92 if self._devnull: |
93 self._devnull.close() | 93 self._devnull.close() |
94 self._devnull = None | 94 self._devnull = None |
OLD | NEW |