当前位置: 首页>>代码示例>>Python>>正文


Python webbrowser.Mozilla方法代码示例

本文整理汇总了Python中webbrowser.Mozilla方法的典型用法代码示例。如果您正苦于以下问题:Python webbrowser.Mozilla方法的具体用法?Python webbrowser.Mozilla怎么用?Python webbrowser.Mozilla使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webbrowser的用法示例。


在下文中一共展示了webbrowser.Mozilla方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new_webbrowser_profile

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import Mozilla [as 别名]
def new_webbrowser_profile():
    if is_command("google-chrome"):
        return _make_chrome("google-chrome")
    elif is_command("firefox"):
        new_firefox = webbrowser.Mozilla()
        new_firefox.name = "firefox"
        profile_directory = tempfile.mkdtemp()
        new_firefox.remote_args = [
            "-profile",
            profile_directory,
            "-new-instance",
            "-no-remote",
            "-url",
            "%s",
        ]
        return new_firefox
    elif sys.platform == "darwin":
        chrome_path = config.get("chrome-path")
        if os.path.exists(chrome_path):
            return _make_chrome(chrome_path)
        else:
            return webbrowser
    else:
        return webbrowser 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:26,代码来源:deployment.py

示例2: test_firefox_isolation

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import Mozilla [as 别名]
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:] == [
            "-new-instance",
            "-no-remote",
            "-url",
            r"%s",
        ] 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:17,代码来源:test_deployment.py

示例3: display_qr_code

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import Mozilla [as 别名]
def display_qr_code(png, seed):
    """
    Display MFA QR code
    :param png:
    :param seed:
    :return:
    """
    # 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')
    qrcode_file.write(png)
    qrcode_file.flush()
    if _fabulous_available:
        fabulous.utils.term.bgcolor = 'white'
        with open(qrcode_file.name, 'rb') as png_file:
            print(fabulous.image.Image(png_file, 100))
    else:
        graphical_browsers = [webbrowser.BackgroundBrowser,
                              webbrowser.Mozilla,
                              webbrowser.Galeon,
                              webbrowser.Chrome,
                              webbrowser.Opera,
                              webbrowser.Konqueror]
        if sys.platform[:3] == 'win':
            graphical_browsers.append(webbrowser.WindowsDefault)
        elif sys.platform == 'darwin':
            graphical_browsers.append(webbrowser.MacOSXOSAScript)

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

        if browser_type in graphical_browsers:
            printError("Unable to print qr code directly to your terminal, trying a web browser.")
            webbrowser.open('file://' + qrcode_file.name)
        else:
            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" % qrcode_file.name)
            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 
开发者ID:nccgroup,项目名称:AWS-recipes,代码行数:58,代码来源:awsrecipes_enable_mfa.py


注:本文中的webbrowser.Mozilla方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。