Python webbrowser.Mozilla() Examples

The following are 3 code examples of webbrowser.Mozilla(). 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:    From Dallinger with MIT License 6 votes vote down vote up
def new_webbrowser_profile():
    if is_command("google-chrome"):
        return _make_chrome("google-chrome")
    elif is_command("firefox"):
        new_firefox = webbrowser.Mozilla() = "firefox"
        profile_directory = tempfile.mkdtemp()
        new_firefox.remote_args = [
        return new_firefox
    elif sys.platform == "darwin":
        chrome_path = config.get("chrome-path")
        if os.path.exists(chrome_path):
            return _make_chrome(chrome_path)
            return webbrowser
        return webbrowser 
Example #2
Source File:    From Dallinger with MIT License 5 votes vote down vote up
def test_firefox_isolation(self):
        import webbrowser

        with mock.patch("dallinger.deployment.is_command") as is_command:
            is_command.side_effect = lambda s: s == "firefox"
            isolated = new_webbrowser_profile()
        assert isinstance(isolated, webbrowser.Mozilla)
        assert isolated.remote_args[0] == "-profile"
        assert isolated.remote_args[1].startswith(tempfile.gettempdir())
        assert isolated.remote_args[2:] == [
Example #3
Source File:    From AWS-recipes with GNU General Public License v2.0 4 votes vote down vote up
def display_qr_code(png, seed):
    Display MFA QR code
    :param png:
    :param seed:
    # This NamedTemporaryFile is deleted as soon as it is closed, so
    # return it to caller, who must close it (or program termination
    # could cause it to be cleaned up, that's fine too).
    # If we don't keep the file around until after the user has synced
    # his MFA, the file will possibly be already deleted by the time
    # the operating system gets around to execing the browser, if
    # we're using a browser.
    qrcode_file = tempfile.NamedTemporaryFile(suffix='.png', delete=True, mode='wt')
    if _fabulous_available:
        fabulous.utils.term.bgcolor = 'white'
        with open(, 'rb') as png_file:
            print(fabulous.image.Image(png_file, 100))
        graphical_browsers = [webbrowser.BackgroundBrowser,
        if sys.platform[:3] == 'win':
        elif sys.platform == 'darwin':

        browser_type = None
            browser_type = type(webbrowser.get())
        except webbrowser.Error:

        if browser_type in graphical_browsers:
            printError("Unable to print qr code directly to your terminal, trying a web browser.")
  'file://' +
            printInfo("Unable to print qr code directly to your terminal, and no graphical web browser seems available.")
            printInfo("But, the qr code file is temporarily available as this file:")
            printInfo("\n    %s\n" %
            printInfo("Alternately, if you feel like typing the seed manually into your MFA app:")
            # this is a base32-encoded binary string (for case
            # insensitivity) which is then dutifully base64-encoded by
            # amazon before putting it on the wire.  so the actual
            # secret is b32decode(b64decode(seed)), and what users
            # will need to type in to their app is just
            # b64decode(seed).  print that out so users can (if
            # desperate) type in their MFA app.
            printInfo("\n    %s\n" % base64.b64decode(seed))
    return qrcode_file