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


Python client.NOT_FOUND属性代码示例

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


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

示例1: save

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def save(self):
        try:
            self.create()

        except K8sApiException as e:
            if e.status == client.NOT_FOUND:
                logging.warning("Third Party Resource is not ready yet. "
                                "Report will be skipped")
                return
            if e.status == client.METHOD_NOT_ALLOWED:
                logging.error("API is blocked. Report will be skipped")
                return
            if e.status != client.CONFLICT:
                raise e
            logging.info("Previous resource has been detected. Recreating...")

            try:
                self.remove()
            except K8sApiException as e:
                if e.status != client.NOT_FOUND:
                    raise e

            self.create() 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:25,代码来源:third_party.py

示例2: save

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def save(self):
        """Save custom object if not exists"""
        try:
            self.create()

        except K8sApiException as e:
            if e.status == client.NOT_FOUND:
                logging.warning("Custom Resource Definition is not ready yet. "
                                "Report will be skipped")
                return
            if e.status == client.METHOD_NOT_ALLOWED:
                logging.error("API is blocked. Report will be skipped")
                return
            if e.status != client.CONFLICT:
                raise e
            logging.warning("Previous definition has been detected. "
                            "Recreating...")

            try:
                self.remove()
            except K8sApiException as e:
                if e.status != client.NOT_FOUND:
                    raise e

            self.create() 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:27,代码来源:custom_resource.py

示例3: test_third_party_resource_save_tpr_not_ready_failure

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_third_party_resource_save_tpr_not_ready_failure(caplog):
    fake_http_resp = FakeHTTPResponse(client.NOT_FOUND, "fake reason",
                                      "fake body")
    fake_api_exception = K8sApiException(http_resp=fake_http_resp)
    mock = MagicMock()
    with patch('intel.k8s.extensions_client_from_config',
               MagicMock(return_value=mock)):
        fake_tpr = FakeTPR.generate_tpr()
        mock_create = MagicMock(side_effect=fake_api_exception)
        with patch('intel.third_party.ThirdPartyResource.create', mock_create):
            fake_tpr.save()
        assert mock_create.called
        exp_log_err = ("Third Party Resource is not ready yet. "
                       "Report will be skipped")
        caplog_tuple = caplog.record_tuples
        assert caplog_tuple[-1][2] == exp_log_err 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:18,代码来源:test_third_party.py

示例4: csp_middleware

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def csp_middleware(get_response):
    def middleware(request):
        nonce_func = partial(make_csp_nonce, request)
        request.csp_nonce = SimpleLazyObject(nonce_func)

        response = get_response(request)

        if CSP_HEADER in response:
            # header already present (HOW ???)
            return response

        if response.status_code in (INTERNAL_SERVER_ERROR, NOT_FOUND) and settings.DEBUG:
            # no policies in debug views
            return response

        response[CSP_HEADER] = build_csp_header(request)

        return response

    return middleware 
开发者ID:zentralopensource,项目名称:zentral,代码行数:22,代码来源:middlewares.py

示例5: readiness_status

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def readiness_status(self):
        data = 'ok'

        if CONF.kubernetes.vif_pool_driver != 'noop':
            if not os.path.exists('/tmp/pools_loaded'):
                error_message = 'Ports not loaded into the pools.'
                LOG.error(error_message)
                return error_message, httplib.NOT_FOUND, self.headers

        k8s_conn = self.verify_k8s_connection()
        if not k8s_conn:
            error_message = 'Error when processing k8s healthz request.'
            LOG.error(error_message)
            return error_message, httplib.INTERNAL_SERVER_ERROR, self.headers
        try:
            self.verify_keystone_connection()
        except Exception as ex:
            error_message = ('Error when creating a Keystone session and '
                             'getting a token: %s.' % ex)
            LOG.exception(error_message)
            return error_message, httplib.INTERNAL_SERVER_ERROR, self.headers

        try:
            if not self._components_ready():
                return '', httplib.INTERNAL_SERVER_ERROR, self.headers
        except Exception as ex:
            error_message = ('Error when processing neutron request %s' % ex)
            LOG.exception(error_message)
            return error_message, httplib.INTERNAL_SERVER_ERROR, self.headers

        LOG.info('Kuryr Controller readiness verified.')
        return data, httplib.OK, self.headers 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:34,代码来源:health.py

示例6: get_gcs_client

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def get_gcs_client(self) -> luigi.contrib.gcs.GCSClient:
        if (not os.path.isfile(self.discover_cache_local_path)):
            with open(self.discover_cache_local_path, "w") as f:
                try:
                    fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)

                    params = {"api": "storage", "apiVersion": "v1"}
                    discovery_http = build_http()
                    for discovery_url in (self._DISCOVERY_URI, self._V2_DISCOVERY_URI):
                        requested_url = uritemplate.expand(discovery_url, params)
                        try:
                            content = _retrieve_discovery_doc(
                                requested_url, discovery_http, False
                            )
                        except HttpError as e:
                            if e.resp.status == http_client.NOT_FOUND:
                                continue
                            else:
                                raise e
                        break
                    f.write(content)
                    fcntl.flock(f, fcntl.LOCK_UN)
                except IOError:
                    # try to read
                    pass

        with open(self.discover_cache_local_path, "r") as f:
            fcntl.flock(f, fcntl.LOCK_SH)
            descriptor = f.read()
            fcntl.flock(f, fcntl.LOCK_UN)
            return luigi.contrib.gcs.GCSClient(oauth_credentials=self._load_oauth_credentials(), descriptor=descriptor) 
开发者ID:m3dev,项目名称:gokart,代码行数:33,代码来源:gcs_config.py

示例7: exists

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def exists(self, namespace="default"):
        header_params = {
            'Content-Type': "application/json",
            'Accept': "application/json"
        }

        auth_settings = ['BearerToken']

        resource_path = "/".join([
            "/apis",
            self.type_url,
            self.type_version,
            "namespaces", namespace,
            self.type_name + "s"
        ])

        try:
            self.api.api_client.call_api(
                resource_path,
                'GET',
                header_params,
                auth_settings=auth_settings)

        except K8sApiException as e:
            if e.status == client.CONFLICT or e.status == client.NOT_FOUND:
                return False
            raise e

        return True 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:31,代码来源:third_party.py

示例8: exists

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def exists(self, namespace="default"):
        """Check if custom resource definition exists"""
        try:
            self.api.api_client.call_api(
                self.resource_path_crd_type,
                'GET',
                self.header_params,
                auth_settings=self.auth_settings)

        except K8sApiException as e:
            if e.status == client.CONFLICT or e.status == client.NOT_FOUND:
                return False
            raise e
        return True 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:16,代码来源:custom_resource.py

示例9: test_custom_resource_type_exists_success2

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_custom_resource_type_exists_success2():
    fake_http_resp = FakeHTTPResponse(client.NOT_FOUND, "fake reason",
                                      "fake body")
    fake_api_exception = K8sApiException(http_resp=fake_http_resp)
    assert fake_api_exception.status == client.NOT_FOUND

    mock = MagicMock()
    with patch('intel.k8s.extensions_client_from_config',
               MagicMock(return_value=mock)):
        fake_type = FakeCRD.generate_crd_type()
        mock.api_client.call_api = MagicMock(side_effect=fake_api_exception)
        exists = fake_type.exists()
        assert not exists 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:15,代码来源:test_custom_resource.py

示例10: test_third_party_resource_type_exists_success2

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_third_party_resource_type_exists_success2():
    fake_http_resp = FakeHTTPResponse(client.NOT_FOUND, "fake reason",
                                      "fake body")
    fake_api_exception = K8sApiException(http_resp=fake_http_resp)
    assert fake_api_exception.status == client.NOT_FOUND
    mock = MagicMock()
    with patch('intel.k8s.extensions_client_from_config',
               MagicMock(return_value=mock)):
        fake_type = FakeTPR.generate_tpr_type()
        mock.api_client.call_api = MagicMock(side_effect=fake_api_exception)
        exists = fake_type.exists()
        assert not exists 
开发者ID:intel,项目名称:CPU-Manager-for-Kubernetes,代码行数:14,代码来源:test_third_party.py

示例11: test_page_not_found_on_root

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_page_not_found_on_root(self):
        r = PsDashRunner({'PSDASH_URL_PREFIX': self.default_prefix})
        resp = r.app.test_client().get('/')
        self.assertEqual(resp.status_code, httplib.NOT_FOUND) 
开发者ID:Jahaja,项目名称:psdash,代码行数:6,代码来源:test_web.py

示例12: test_process_non_existing_pid

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_process_non_existing_pid(self):
        resp = self.client.get('/process/0')
        self.assertEqual(resp.status_code, httplib.NOT_FOUND) 
开发者ID:Jahaja,项目名称:psdash,代码行数:5,代码来源:test_web.py

示例13: test_process_invalid_section

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_process_invalid_section(self):
        resp = self.client.get('/process/%d/whatnot' % self.pid)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND) 
开发者ID:Jahaja,项目名称:psdash,代码行数:5,代码来源:test_web.py

示例14: test_non_existing

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_non_existing(self):
        resp = self.client.get('/prettywronghuh')
        self.assertEqual(resp.status_code, httplib.NOT_FOUND) 
开发者ID:Jahaja,项目名称:psdash,代码行数:5,代码来源:test_web.py

示例15: test_non_existing_file

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import NOT_FOUND [as 别名]
def test_non_existing_file(self):
        filename = "/var/log/surelynotaroundright.log"

        resp = self.client.get('/log?filename=%s' % filename)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

        resp = self.client.get('/log/search?filename=%s&text=%s' % (filename, 'something'))
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

        resp = self.client.get('/log/read?filename=%s' % filename)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND)

        resp = self.client.get('/log/read_tail?filename=%s' % filename)
        self.assertEqual(resp.status_code, httplib.NOT_FOUND) 
开发者ID:Jahaja,项目名称:psdash,代码行数:16,代码来源:test_web.py


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