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


Python httputil.url_concat方法代码示例

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


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

示例1: _oauth_request_token_url

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def _oauth_request_token_url(
        self,
        redirect_uri: str = None,
        client_id: str = None,
        client_secret: str = None,
        code: str = None,
        extra_params: Dict[str, Any] = None,
    ) -> str:
        url = self._OAUTH_ACCESS_TOKEN_URL  # type: ignore
        args = {}  # type: Dict[str, str]
        if redirect_uri is not None:
            args["redirect_uri"] = redirect_uri
        if code is not None:
            args["code"] = code
        if client_id is not None:
            args["client_id"] = client_id
        if client_secret is not None:
            args["client_secret"] = client_secret
        if extra_params:
            args.update(extra_params)
        return url_concat(url, args) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:23,代码来源:auth.py

示例2: get_auth_request

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def get_auth_request(self, code):
        params = dict(
            redirect_uri=self.oauth_callback_url,
            code=code,
            grant_type='authorization_code',
        )
        b64key = a2b_base64("{}:{}".format(self.client_id, self.client_secret)).decode(
            'ascii'
        )
        url = url_concat(self.token_url, params)
        req = HTTPRequest(
            url,
            method="POST",
            headers={
                "Accept": "application/json",
                "User-Agent": "JupyterHub",
                "Authorization": "Basic {}".format(b64key),
            },
            body='',  # Body is required for a POST...
        )
        return req 
开发者ID:jupyterhub,项目名称:oauthenticator,代码行数:23,代码来源:okpy.py

示例3: _check_team_whitelist

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def _check_team_whitelist(self, username, access_token):
        http_client = AsyncHTTPClient()

        headers = _api_headers(access_token)
        # We verify the team membership by calling teams endpoint.
        next_page = url_concat(
            "https://api.bitbucket.org/2.0/teams", {'role': 'member'}
        )
        while next_page:
            req = HTTPRequest(next_page, method="GET", headers=headers)
            resp = await http_client.fetch(req)
            resp_json = json.loads(resp.body.decode('utf8', 'replace'))
            next_page = resp_json.get('next', None)

            user_teams = set([entry["username"] for entry in resp_json["values"]])
            # check if any of the organizations seen thus far are in whitelist
            if len(self.bitbucket_team_whitelist & user_teams) > 0:
                return True
        return False 
开发者ID:jupyterhub,项目名称:oauthenticator,代码行数:21,代码来源:bitbucket.py

示例4: _render

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def _render(self, login_error=None, username=None):
        self._register_template_path()
        return self.render_template(
            'native-login.html',
            next=url_escape(self.get_argument('next', default='')),
            username=username,
            login_error=login_error,
            custom_html=self.authenticator.custom_html,
            login_url=self.settings['login_url'],
            enable_signup=self.authenticator.enable_signup,
            two_factor_auth=self.authenticator.allow_2fa,
            authenticator_login_url=url_concat(
                self.authenticator.login_url(self.hub.base_url),
                {'next': self.get_argument('next', '')},
            ),
        ) 
开发者ID:jupyterhub,项目名称:nativeauthenticator,代码行数:18,代码来源:handlers.py

示例5: authorize_redirect

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def authorize_redirect(self, redirect_uri=None, client_id=None,
                           client_secret=None, extra_params=None):
        """Redirects the user to obtain OAuth authorization for this service.

        Some providers require that you register a Callback
        URL with your application. You should call this method to log the
        user in, and then call get_authenticated_user() in the handler
        you registered as your Callback URL to complete the authorization
        process.
        """
        args = {
          "redirect_uri": redirect_uri,
          "client_id": client_id
        }
        if extra_params:
            args.update(extra_params)
        self.redirect(
                url_concat(self._OAUTH_AUTHORIZE_URL, args)) 
开发者ID:omererdem,项目名称:honeything,代码行数:20,代码来源:auth.py

示例6: test_build

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def test_build(app, needs_build, needs_launch, always_build, slug, pytestconfig):
    # can't use mark.github_api since only some tests here use GitHub
    if slug.startswith('gh/') and "not github_api" in pytestconfig.getoption('markexpr'):
        pytest.skip("Skipping GitHub API test")
    build_url = f"{app.url}/build/{slug}"
    r = await async_requests.get(build_url, stream=True)
    r.raise_for_status()
    events = []
    async for line in async_requests.iter_lines(r):
        line = line.decode('utf8', 'replace')
        if line.startswith('data:'):
            event = json.loads(line.split(':', 1)[1])
            events.append(event)
            assert 'message' in event
            sys.stdout.write(event['message'])

    final = events[-1]
    assert 'phase' in final
    assert final['phase'] == 'ready'
    assert 'url' in final
    assert 'token' in final
    print(final['url'])
    r = await async_requests.get(url_concat(final['url'], {'token': final['token']}))
    r.raise_for_status()
    assert r.url.startswith(final['url']) 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:27,代码来源:test_build.py

示例7: commit_container

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def commit_container(request, spawner, log):
    image_tag = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
    image_name = 'everware_image/' + spawner.escaped_name + '/' + spawner.escaped_repo_url + '_' + spawner.container_id
    host_with_protocol = request.protocol + '://' + request.host
    url_with_image = url_concat(host_with_protocol + '/hub/spawn',
                                dict(repourl='docker:' + image_name + ':' + image_tag))

    log.info('Will commit %s' % url_with_image)

    commit = yield spawner.docker(
        'commit',
        container=spawner.container_id,
        repository=image_name,
        tag=image_tag,
        message='Commit from control panel',
        author=spawner.escaped_name
    )

    output_data = dict()
    if commit:
        output_data['url_with_image'] = url_with_image
    else:
        output_data['message'] = 'Sorry, can not save container'

    return output_data 
开发者ID:everware,项目名称:everware,代码行数:27,代码来源:home_handler.py

示例8: _check_group_whitelist

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def _check_group_whitelist(self, username, headers):
        http_client = AsyncHTTPClient()

        # We verify the team membership by calling teams endpoint.
        # Re-use the headers, change the request.
        next_page = url_concat("https://api.bitbucket.org/2.0/teams",
                               {'role': 'member'})
        user_teams = set()
        while next_page:
            req = HTTPRequest(next_page, method="GET", headers=headers)
            resp = yield http_client.fetch(req)
            resp_json = json.loads(resp.body.decode('utf8', 'replace'))
            next_page = resp_json.get('next', None)

            user_teams |= \
                set([entry["username"] for entry in resp_json["values"]])
        return len(self.team_whitelist & user_teams) > 0 
开发者ID:everware,项目名称:everware,代码行数:19,代码来源:authenticator.py

示例9: authorize_redirect

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def authorize_redirect(self, redirect_uri=None, client_id=None,
                           client_secret=None, extra_params=None,
                           callback=None, scope=None, response_type="code"):
        """Redirects the user to obtain OAuth authorization for this service.

        Some providers require that you register a redirect URL with
        your application instead of passing one via this method. You
        should call this method to log the user in, and then call
        ``get_authenticated_user`` in the handler for your
        redirect URL to complete the authorization process.

        .. versionchanged:: 3.1
           Returns a `.Future` and takes an optional callback.  These are
           not strictly necessary as this method is synchronous,
           but they are supplied for consistency with
           `OAuthMixin.authorize_redirect`.
        """
        args = {
            "redirect_uri": redirect_uri,
            "client_id": client_id,
            "response_type": response_type
        }
        if extra_params:
            args.update(extra_params)
        if scope:
            args['scope'] = ' '.join(scope)
        self.redirect(
            url_concat(self._OAUTH_AUTHORIZE_URL, args))
        callback() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:31,代码来源:auth.py

示例10: _oauth_request_token_url

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def _oauth_request_token_url(self, redirect_uri=None, client_id=None,
                                 client_secret=None, code=None,
                                 extra_params=None):
        url = self._OAUTH_ACCESS_TOKEN_URL
        args = dict(
            redirect_uri=redirect_uri,
            code=code,
            client_id=client_id,
            client_secret=client_secret,
        )
        if extra_params:
            args.update(extra_params)
        return url_concat(url, args) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:15,代码来源:auth.py

示例11: get

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def get(self):
        # issue a fake auth code and redirect to redirect_uri
        code = 'fake-authorization-code'
        self.redirect(url_concat(self.get_argument('redirect_uri'),
                                 dict(code=code))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:auth_test.py

示例12: test_url_concat_no_query_params

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def test_url_concat_no_query_params(self):
        url = url_concat(
            "https://localhost/path",
            [('y', 'y'), ('z', 'z')],
        )
        self.assertEqual(url, "https://localhost/path?y=y&z=z") 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:8,代码来源:httputil_test.py

示例13: test_url_concat_encode_args

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def test_url_concat_encode_args(self):
        url = url_concat(
            "https://localhost/path",
            [('y', '/y'), ('z', 'z')],
        )
        self.assertEqual(url, "https://localhost/path?y=%2Fy&z=z") 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:8,代码来源:httputil_test.py

示例14: test_url_concat_q_with_no_trailing_amp

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def test_url_concat_q_with_no_trailing_amp(self):
        url = url_concat(
            "https://localhost/path?x",
            [('y', 'y'), ('z', 'z')],
        )
        self.assertEqual(url, "https://localhost/path?x&y=y&z=z") 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:8,代码来源:httputil_test.py

示例15: test_url_concat_trailing_amp

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import url_concat [as 别名]
def test_url_concat_trailing_amp(self):
        url = url_concat(
            "https://localhost/path?x&",
            [('y', 'y'), ('z', 'z')],
        )
        self.assertEqual(url, "https://localhost/path?x&y=y&z=z") 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:8,代码来源:httputil_test.py


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