當前位置: 首頁>>代碼示例>>Python>>正文


Python falcon.HTTP_500屬性代碼示例

本文整理匯總了Python中falcon.HTTP_500屬性的典型用法代碼示例。如果您正苦於以下問題:Python falcon.HTTP_500屬性的具體用法?Python falcon.HTTP_500怎麽用?Python falcon.HTTP_500使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在falcon的用法示例。


在下文中一共展示了falcon.HTTP_500屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_get

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def on_get(self, req, resp):
        """Method handler for GET requests.

        :param req: Falcon request object
        :param resp: Falcon response object
        """
        state = self.state_manager

        try:
            designs = list(state.designs.keys())

            resp.body = json.dumps(designs)
            resp.status = falcon.HTTP_200
        except Exception as ex:
            self.error(req.context, "Exception raised: %s" % str(ex))
            self.return_error(
                resp,
                falcon.HTTP_500,
                message="Error accessing design list",
                retry=True) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:22,代碼來源:designs.py

示例2: on_post

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def on_post(self, req, resp):
        try:
            json_data = self.req_json(req)
            node_filter = json_data.get('node_filter', None)
            design_ref = json_data.get('design_ref', None)
            if design_ref is None:
                self.info(req.context,
                          'Missing required input value: design_ref')
                self.return_error(
                    resp,
                    falcon.HTTP_400,
                    message='Missing input required value: design_ref',
                    retry=False)
                return
            _, site_design = self.orchestrator.get_effective_site(design_ref)
            nodes = self.orchestrator.process_node_filter(
                node_filter=node_filter, site_design=site_design)
            resp_list = [n.name for n in nodes if nodes]

            resp.body = json.dumps(resp_list)
            resp.status = falcon.HTTP_200
        except Exception as ex:
            self.error(req.context, "Unknown error: %s" % str(ex), exc_info=ex)
            self.return_error(
                resp, falcon.HTTP_500, message="Unknown error", retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:27,代碼來源:nodes.py

示例3: task_validate_design

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_validate_design(self, req, resp, json_data):
        """Create async task for validate design."""
        action = json_data.get('action', None)

        if action != 'validate_design':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_validate_design"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例4: task_verify_site

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_verify_site(self, req, resp, json_data):
        """Create async task for verify site."""
        action = json_data.get('action', None)

        if action != 'verify_site':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_verify_site"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例5: task_verify_nodes

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_verify_nodes(self, req, resp, json_data):
        """Create async task for verify node."""
        action = json_data.get('action', None)

        if action != 'verify_nodes':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_verify_nodes"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例6: task_prepare_nodes

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_prepare_nodes(self, req, resp, json_data):
        """Create async task for prepare node."""
        action = json_data.get('action', None)

        if action != 'prepare_nodes':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_prepare_nodes"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例7: task_deploy_nodes

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_deploy_nodes(self, req, resp, json_data):
        """Create async task for deploy node."""
        action = json_data.get('action', None)

        if action != 'deploy_nodes':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_deploy_nodes"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例8: task_destroy_nodes

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_destroy_nodes(self, req, resp, json_data):
        """Create async task for destroy node."""
        action = json_data.get('action', None)

        if action != 'destroy_nodes':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_destroy_nodes"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例9: task_relabel_nodes

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def task_relabel_nodes(self, req, resp, json_data):
        """Create async task for relabel nodes."""
        action = json_data.get('action', None)

        if action != 'relabel_nodes':
            self.error(
                req.context,
                "Task body ended up in wrong handler: action %s in task_relabel_nodes"
                % action)
            self.return_error(
                resp, falcon.HTTP_500, message="Error", retry=False)

        try:
            task = self.create_task(json_data, req.context)
            resp.body = json.dumps(task.to_dict())
            resp.append_header('Location',
                               "/api/v1.0/tasks/%s" % str(task.task_id))
            resp.status = falcon.HTTP_201
        except errors.InvalidFormat as ex:
            self.error(req.context, ex.msg)
            self.return_error(
                resp, falcon.HTTP_400, message=ex.msg, retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:24,代碼來源:tasks.py

示例10: get_task

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def get_task(self, req, resp, task_id, builddata):
        try:
            task = self.state_manager.get_task(uuid.UUID(task_id))
            if task is None:
                return None

            task_dict = task.to_dict()

            if builddata:
                task_bd = self.state_manager.get_build_data(
                    task_id=task.get_id())
                task_dict['build_data'] = [bd.to_dict() for bd in task_bd]

            return task_dict
        except Exception as ex:
            self.error(req.context, "Unknown error: %s" % (str(ex)))
            self.return_error(
                resp, falcon.HTTP_500, message="Unknown error", retry=False) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:20,代碼來源:tasks.py

示例11: on_post

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def on_post(self, req, resp, release):
        try:
            with self.get_tiller(req, resp) as tiller:
                msg = self.handle(req, release, tiller)
                resp.body = json.dumps({
                    'message': msg,
                })
                resp.content_type = 'application/json'
                resp.status = falcon.HTTP_200
        except LockException as e:
            self.return_error(resp, falcon.HTTP_409, message=str(e))
        except Exception as e:
            self.logger.exception('Caught unexpected exception')
            err_message = 'Failed to rollback release: {}'.format(e)
            self.error(req.context, err_message)
            self.return_error(resp, falcon.HTTP_500, message=err_message) 
開發者ID:airshipit,項目名稱:armada,代碼行數:18,代碼來源:rollback.py

示例12: on_get

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def on_get(self, req, resp):
        '''Controller for listing Tiller releases.
        '''
        try:
            with self.get_tiller(req, resp) as tiller:
                releases = self.handle(tiller)
                resp.body = json.dumps({
                    'releases': releases,
                })
                resp.content_type = 'application/json'
                resp.status = falcon.HTTP_200

        except Exception as e:
            err_message = 'Unable to find Tiller Releases: {}'.format(e)
            self.error(req.context, err_message)
            self.return_error(resp, falcon.HTTP_500, message=err_message) 
開發者ID:airshipit,項目名稱:armada,代碼行數:18,代碼來源:tiller.py

示例13: default_exception_handler

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def default_exception_handler(ex, req, resp, params):
    """
    Catch-all exception handler for standardized output.
    If this is a standard falcon HTTPError, rethrow it for handling
    """
    if isinstance(ex, falcon.HTTPError):
        # allow the falcon http errors to bubble up and get handled
        raise ex
    else:
        # take care of the uncaught stuff
        exc_string = traceback.format_exc()
        logging.error('Unhanded Exception being handled: \n%s', exc_string)
        format_error_resp(
            req,
            resp,
            falcon.HTTP_500,
            error_type=ex.__class__.__name__,
            message="Unhandled Exception raised: %s" % str(ex),
            retry=True
        ) 
開發者ID:att-comdev,項目名稱:armada,代碼行數:22,代碼來源:errors.py

示例14: default_error_handler

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def default_error_handler(req, resp, e):
    resp.body = json.dumps({'title': str(type(e)), 'description': str(e)}, indent=2, ensure_ascii=False)
    resp.status = falcon.HTTP_500
    resp.content_type = 'application/json'


# def http_not_found_handler(req, resp, e):
#     resp.body = e.title
#     resp.status = e.status
#     resp.content_type = 'application/json'
#
#
# def http_missing_param_handler(req, resp, e):
#     resp.body = json.dumps({'error': e.title + ':' + ' '.join([p for p in e.args])})
#     resp.status = e.status
#     resp.content_type = 'application/json'
#
#
# def http_invalid_param_handler(req, resp, e):
#     resp.body = json.dumps({'error': e.title + ':' + ' '.join([p for p in e.args])})
#     resp.status = e.status
#     resp.content_type = 'application/json' 
開發者ID:pingf,項目名稱:falsy,代碼行數:24,代碼來源:swagger_server.py

示例15: default_exception_handler

# 需要導入模塊: import falcon [as 別名]
# 或者: from falcon import HTTP_500 [as 別名]
def default_exception_handler(ex, req, resp, params):
    """
    Catch-all exception handler for standardized output.
    If this is a standard falcon HTTPError, rethrow it for handling
    """
    if isinstance(ex, falcon.HTTPError):
        # allow the falcon http errors to bubble up and get handled
        raise ex
    else:
        # take care of the uncaught stuff
        exc_string = traceback.format_exc()
        LOG.error('Unhanded Exception being handled: \n%s', exc_string)
        format_error_resp(
            req,
            resp,
            falcon.HTTP_500,
            error_type=ex.__class__.__name__,
            message="Unhandled Exception raised: %s" % str(ex),
            retry=True) 
開發者ID:airshipit,項目名稱:promenade,代碼行數:21,代碼來源:exceptions.py


注:本文中的falcon.HTTP_500屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。