auth.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:deb-python-dcos 作者: openstack 项目源码 文件源码
def _prompt_user_for_token(url, token_type):
    """Get Token from user

    :param url: url for user to go to
    :type url: str
    :param token_type: type of token to be received
    :type token_type: str
    :returns: token show to user by browser
    :rtype: str
    """

    msg = textwrap.dedent("""\
        If your browser didn't open, please go to the following link:

            {url}

        Enter {token_type}: """)
    msg = msg.lstrip().format(url=url, token_type=token_type)

    try:
        webbrowser.open_new_tab(url)
    except webbrowser.Error as exc:
        logger.warning(
            'Exception occurred while calling webbrowser.open(%r): %s',
            url, exc,
        )
        pass
    sys.stderr.write(msg)
    sys.stderr.flush()
    token = sys.stdin.readline().strip()
    return token
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号