本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
)
示例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'
示例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)