當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。