OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Finds desktop browsers that can be controlled by telemetry.""" | 4 """Finds desktop browsers that can be controlled by telemetry.""" |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 import dependency_manager # pylint: disable=import-error | 10 import dependency_manager # pylint: disable=import-error |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 def Create(self, finder_options): | 53 def Create(self, finder_options): |
54 if self._flash_path and not os.path.exists(self._flash_path): | 54 if self._flash_path and not os.path.exists(self._flash_path): |
55 logging.warning( | 55 logging.warning( |
56 'Could not find Flash at %s. Continuing without Flash.\n' | 56 'Could not find Flash at %s. Continuing without Flash.\n' |
57 'To run with Flash, check it out via http://go/read-src-internal', | 57 'To run with Flash, check it out via http://go/read-src-internal', |
58 self._flash_path) | 58 self._flash_path) |
59 self._flash_path = None | 59 self._flash_path = None |
60 | 60 |
61 self._InitPlatformIfNeeded() | 61 self._InitPlatformIfNeeded() |
62 | 62 |
63 browser_backend = desktop_browser_backend.DesktopBrowserBackend( | 63 num_retries = 3 |
64 self._platform_backend, | 64 for x in range(0, num_retries): |
65 finder_options.browser_options, self._local_executable, | 65 returned_browser = None |
66 self._flash_path, self._is_content_shell, self._browser_directory) | 66 try: |
67 return browser.Browser( | 67 returned_browser = None |
68 browser_backend, self._platform_backend, self._credentials_path) | 68 restart = 'Starting browser, attempt %d of %d' % ((x + 1), num_retries) |
nednguyen
2017/05/07 23:47:43
Can you remove this the line below. We shouldn't a
Ken Russell (switch to Gerrit)
2017/05/08 20:44:11
Yes, done.
| |
69 logging.warning(restart) | |
70 | |
71 browser_backend = desktop_browser_backend.DesktopBrowserBackend( | |
72 self._platform_backend, | |
73 finder_options.browser_options, self._local_executable, | |
74 self._flash_path, self._is_content_shell, self._browser_directory) | |
75 | |
76 returned_browser = browser.Browser( | |
77 browser_backend, self._platform_backend, self._credentials_path) | |
78 | |
79 # Try fetching the zeroth tab. If this works, then the browser | |
80 # appears to be working. | |
81 _ = returned_browser.tabs[0] | |
82 | |
83 logging.warning('Started browser successfully.') | |
nednguyen
2017/05/07 23:47:43
I think this log is not needed.
Ken Russell (switch to Gerrit)
2017/05/08 20:44:11
OK, removed.
| |
84 return returned_browser | |
85 except Exception: | |
86 logging.warning('Browser creation failed, retrying') | |
nednguyen
2017/05/07 23:47:43
logging.warning('Browser creation failed, retrying
Ken Russell (switch to Gerrit)
2017/05/08 20:44:11
Done, slightly rephrased.
| |
87 # Attempt to clean up things left over from the failed browser startup. | |
88 try: | |
89 if returned_browser: | |
90 returned_browser.Close() | |
91 except Exception: | |
92 pass | |
93 # Re-raise the exception the last time through. | |
94 if x == num_retries - 1: | |
95 raise | |
69 | 96 |
70 def SupportsOptions(self, browser_options): | 97 def SupportsOptions(self, browser_options): |
71 if ((len(browser_options.extensions_to_load) != 0) | 98 if ((len(browser_options.extensions_to_load) != 0) |
72 and self._is_content_shell): | 99 and self._is_content_shell): |
73 return False | 100 return False |
74 return True | 101 return True |
75 | 102 |
76 def UpdateExecutableIfNeeded(self): | 103 def UpdateExecutableIfNeeded(self): |
77 pass | 104 pass |
78 | 105 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 if "--ozone-platform" in arg: | 306 if "--ozone-platform" in arg: |
280 has_ozone_platform = True | 307 has_ozone_platform = True |
281 | 308 |
282 if len(browsers) and not has_x11_display and not has_ozone_platform: | 309 if len(browsers) and not has_x11_display and not has_ozone_platform: |
283 logging.warning( | 310 logging.warning( |
284 'Found (%s), but you do not have a DISPLAY environment set.' % | 311 'Found (%s), but you do not have a DISPLAY environment set.' % |
285 ','.join([b.browser_type for b in browsers])) | 312 ','.join([b.browser_type for b in browsers])) |
286 return [] | 313 return [] |
287 | 314 |
288 return browsers | 315 return browsers |
OLD | NEW |