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


Python codes.not_found方法代码示例

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


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

示例1: _raise_response_exceptions

# 需要导入模块: from requests import codes [as 别名]
# 或者: from requests.codes import not_found [as 别名]
def _raise_response_exceptions(response):
    """Raise specific errors on some status codes."""
    if not response.ok and 'www-authenticate' in response.headers:
        msg = response.headers['www-authenticate']
        if 'insufficient_scope' in msg:
            raise OAuthInsufficientScope('insufficient_scope', response.url)
        elif 'invalid_token' in msg:
            raise OAuthInvalidToken('invalid_token', response.url)
        else:
            raise OAuthException(msg, response.url)

    if response.status_code == codes.forbidden:  # pylint: disable=E1101
        raise Forbidden(_raw=response)
    elif response.status_code == codes.not_found:  # pylint: disable=E1101
        raise NotFound(_raw=response)
    else:
        try:
            response.raise_for_status()  # These should all be directly mapped
        except exceptions.HTTPError as exc:
            raise HTTPException(_raw=exc.response) 
开发者ID:tildeclub,项目名称:ttrv,代码行数:22,代码来源:internal.py

示例2: _rest_get_hostconfigs

# 需要导入模块: from requests import codes [as 别名]
# 或者: from requests.codes import not_found [as 别名]
def _rest_get_hostconfigs(self):
        try:
            response = self.odl_rest_client.get()
            response.raise_for_status()
            hostconfigs = response.json()['hostconfigs']['hostconfig']
        except exceptions.ConnectionError:
            LOG.error("Cannot connect to the OpenDaylight Controller",
                      exc_info=True)
            return None
        except exceptions.HTTPError as e:
            # restconf returns 404 on operation when there is no entry
            if e.response.status_code == codes.not_found:
                LOG.debug("Response code not_found (404)"
                          " treated as an empty list")
                return []

            LOG.warning("REST/GET odl hostconfig failed, ",
                        exc_info=True)
            return None
        except KeyError:
            LOG.error("got invalid hostconfigs", exc_info=True)
            return None
        except Exception:
            LOG.warning("REST/GET odl hostconfig failed, ",
                        exc_info=True)
            return None
        else:
            if LOG.isEnabledFor(logging.DEBUG):
                _hconfig_str = jsonutils.dumps(
                    response, sort_keys=True, indent=4, separators=(',', ': '))
                LOG.debug("ODLPORTBINDING hostconfigs:\n%s", _hconfig_str)

        return hostconfigs 
开发者ID:openstack,项目名称:networking-odl,代码行数:35,代码来源:pseudo_agentdb_binding.py


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