Python webbrowser.GenericBrowser() Examples
The following are 2
code examples of webbrowser.GenericBrowser().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
webbrowser
, or try the search function
.
Example #1
Source File: openmct.py From AIT-Core with MIT License | 6 votes |
def start_browser(self, url, name=None): browser = None if name is not None and name.lower() == 'none': log.info('Will not start any browser since --browser=none') return try: browser = webbrowser.get(name) except webbrowser.Error: old = name or 'default' msg = 'Could not find browser: %s. Will use: %s.' browser = webbrowser.get() log.warn(msg, name, self.getBrowserName(browser)) if type(browser) is webbrowser.GenericBrowser: msg = 'Will not start text-based browser: %s.' log.info(msg % self.getBrowserName(browser)) elif browser is not None: log.info('Starting browser: %s' % self.getBrowserName(browser)) browser.open_new(url)
Example #2
Source File: test_objects.py From rtv with MIT License | 6 votes |
def test_patch_webbrowser(*_): # Make sure that webbrowser re-generates the browser list using the # mocked environment import webbrowser webbrowser = reload_module(webbrowser) # By default, we expect that BROWSER will be loaded as a generic browser # This is because "safari" is not a valid script in the system PATH assert isinstance(webbrowser.get(), webbrowser.GenericBrowser) # After patching, the default webbrowser should now be interpreted as an # OSAScript browser patch_webbrowser() assert isinstance(webbrowser.get(), webbrowser.MacOSXOSAScript) assert webbrowser._tryorder[0] == 'safari'