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


Python client.INTERNAL_SERVER_ERROR属性代码示例

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


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

示例1: add

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def add(self):
        try:
            params = self._prepare_request()
        except Exception:
            LOG.exception('Exception when reading CNI params.')
            return '', httplib.BAD_REQUEST, self.headers

        try:
            vif = self.plugin.add(params)
            data = jsonutils.dumps(vif.obj_to_primitive())
        except exception.ResourceNotReady:
            LOG.error('Error when processing addNetwork request')
            return '', httplib.GATEWAY_TIMEOUT, self.headers
        except Exception:
            LOG.exception('Error when processing addNetwork request. CNI '
                          'Params: %s', params)
            return '', httplib.INTERNAL_SERVER_ERROR, self.headers

        return data, httplib.ACCEPTED, self.headers 
开发者ID:openstack,项目名称:zun,代码行数:21,代码来源:service.py

示例2: delete

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def delete(self):
        try:
            params = self._prepare_request()
        except Exception:
            LOG.exception('Exception when reading CNI params.')
            return '', httplib.BAD_REQUEST, self.headers

        try:
            self.plugin.delete(params)
        except exception.ResourceNotReady:
            # NOTE(dulek): It's better to ignore this error - most of the time
            #              it will happen when capsule is long gone and runtime
            #              overzealously tries to delete it from the network.
            #              We cannot really do anything without VIF metadata,
            #              so let's just tell runtime to move along.
            LOG.warning('Error when processing delNetwork request. '
                        'Ignoring this error, capsule is most likely gone')
            return '', httplib.NO_CONTENT, self.headers
        except Exception:
            LOG.exception('Error when processing delNetwork request. CNI '
                          'Params: %s.', params)
            return '', httplib.INTERNAL_SERVER_ERROR, self.headers
        return '', httplib.NO_CONTENT, self.headers 
开发者ID:openstack,项目名称:zun,代码行数:25,代码来源:service.py

示例3: add

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def add(self):
        try:
            params = self._prepare_request()
        except Exception:
            self._check_failure()
            LOG.exception('Exception when reading CNI params.')
            return '', httplib.BAD_REQUEST, self.headers

        try:
            vif = self.plugin.add(params)
            data = jsonutils.dumps(vif.obj_to_primitive())
        except exceptions.ResourceNotReady:
            self._check_failure()
            LOG.error('Error when processing addNetwork request')
            return '', httplib.GATEWAY_TIMEOUT, self.headers
        except Exception:
            self._check_failure()
            LOG.exception('Error when processing addNetwork request. CNI '
                          'Params: %s', params)
            return '', httplib.INTERNAL_SERVER_ERROR, self.headers

        return data, httplib.ACCEPTED, self.headers 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:24,代码来源:service.py

示例4: delete

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def delete(self):
        try:
            params = self._prepare_request()
        except Exception:
            LOG.exception('Exception when reading CNI params.')
            return '', httplib.BAD_REQUEST, self.headers

        try:
            self.plugin.delete(params)
        except exceptions.ResourceNotReady:
            # NOTE(dulek): It's better to ignore this error - most of the time
            #              it will happen when pod is long gone and CRI
            #              overzealously tries to delete it from the network.
            #              We cannot really do anything without VIF annotation,
            #              so let's just tell CRI to move along.
            LOG.warning('Error when processing delNetwork request. '
                        'Ignoring this error, pod is most likely gone')
            return '', httplib.NO_CONTENT, self.headers
        except Exception:
            self._check_failure()
            LOG.exception('Error when processing delNetwork request. CNI '
                          'Params: %s.', params)
            return '', httplib.INTERNAL_SERVER_ERROR, self.headers
        return '', httplib.NO_CONTENT, self.headers 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:26,代码来源:service.py

示例5: csp_middleware

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [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

示例6: test_client_bad_request_with_parameters

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def test_client_bad_request_with_parameters(jedihttp):
    filepath = utils.fixture_filepath('goto.py')
    request_data = {
        'source': read_file(filepath),
        'line': 100,
        'col': 1,
        'source_path': filepath
    }

    response = requests.post(
        'http://127.0.0.1:{0}/gotodefinition'.format(PORT),
        json=request_data,
        auth=HmacAuth(SECRET))

    assert_that(response.status_code, equal_to(httplib.INTERNAL_SERVER_ERROR))

    hmachelper = hmaclib.JediHTTPHmacHelper(SECRET)
    assert_that(hmachelper.is_response_authenticated(response.headers,
                                                     response.content)) 
开发者ID:vheon,项目名称:JediHTTP,代码行数:21,代码来源:end_to_end_test.py

示例7: readiness_status

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [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

示例8: liveness_status

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def liveness_status(self):
        data = 'ok'
        for component in self._registry:
            if not component.is_alive():
                LOG.debug('Kuryr Controller not healthy.')
                return '', httplib.INTERNAL_SERVER_ERROR, self.headers
        LOG.debug('Kuryr Controller Liveness verified.')
        return data, httplib.OK, self.headers 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:10,代码来源:health.py

示例9: readiness_status

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

        if not _has_cap(CAP_NET_ADMIN, EFFECTIVE_CAPS):
            error_message = 'NET_ADMIN capabilities not present.'
            LOG.error(error_message)
            return error_message, httplib.INTERNAL_SERVER_ERROR, self.headers
        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

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

示例10: raise_for_response

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def raise_for_response(method, url, response):
    """Raise a correct error class, if needed."""
    if response.status_code < http_client.BAD_REQUEST:
        return
    elif response.status_code == http_client.NOT_FOUND:
        raise ResourceNotFoundError(method, url, response)
    elif response.status_code == http_client.BAD_REQUEST:
        raise BadRequestError(method, url, response)
    elif response.status_code in (http_client.UNAUTHORIZED,
                                  http_client.FORBIDDEN):
        raise AccessError(method, url, response)
    elif response.status_code >= http_client.INTERNAL_SERVER_ERROR:
        raise ServerSideError(method, url, response)
    else:
        raise HTTPError(method, url, response) 
开发者ID:openstack,项目名称:sushy,代码行数:17,代码来源:exceptions.py

示例11: test_server_error

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def test_server_error(self):
        self.request.return_value.status_code = (
            http_client.INTERNAL_SERVER_ERROR)
        self.request.return_value.json.side_effect = ValueError('no json')

        with self.assertRaisesRegex(exceptions.ServerSideError,
                                    'unknown error') as cm:
            self.conn._op('GET', 'http://foo.bar')
        exc = cm.exception
        self.assertEqual(http_client.INTERNAL_SERVER_ERROR, exc.status_code) 
开发者ID:openstack,项目名称:sushy,代码行数:12,代码来源:test_connector.py

示例12: process_web_request

# 需要导入模块: from http import client [as 别名]
# 或者: from http.client import INTERNAL_SERVER_ERROR [as 别名]
def process_web_request(self, request, path, params, fragment):
    """Implements CommandHandler."""
    options = dict(get_global_options())
    options.update(params)

    if str(params.get('clear_all')).lower() != 'true':
      stackdriver = stackdriver_service.make_service(options)
      audit_results = stackdriver_descriptors.AuditResults(stackdriver)
      descriptor_list = audit_results.descriptor_map.values()
      descriptor_html = '\n<li> '.join(item['type'] for item in descriptor_list)
      html = textwrap.dedent("""\
          Clearing descriptors requires query parameter
          <code>clear_all=true</code>.
          <p/>
          Here are the {count} custom descriptors:
          <ul>
          <li>{descriptors}
          </ul>
          <p/>
          <a href="{path}?clear_all=true">Yes, delete everything!</a>
      """.format(count=len(descriptor_list),
                 descriptors=descriptor_html,
                 path=path))

      html_doc = http_server.build_html_document(
          html, title='Missing Parameters')
      request.respond(
          400, {'ContentType': 'text/html'}, html_doc)
      return

    audit_results = self.__do_clear(options)
    response_code = (httplib.OK if audit_results.obsoleted_count == 0
                     else httplib.INTERNAL_SERVER_ERROR)
    headers = {'Content-Type': 'text/plain'}
    body = audit_results_to_output(
        audit_results, "No custom descriptors to delete.")
    request.respond(response_code, headers, body) 
开发者ID:spinnaker,项目名称:spinnaker-monitoring,代码行数:39,代码来源:stackdriver_handlers.py


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