本文整理汇总了Python中falcon.HTTP_404属性的典型用法代码示例。如果您正苦于以下问题:Python falcon.HTTP_404属性的具体用法?Python falcon.HTTP_404怎么用?Python falcon.HTTP_404使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类falcon
的用法示例。
在下文中一共展示了falcon.HTTP_404属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_get
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def on_get(self, req, resp, design_id):
"""Method Handler for GET design singleton.
:param req: Falcon request object
:param resp: Falcon response object
:param design_id: UUID of the design resource
"""
source = req.params.get('source', 'designed')
try:
design = None
if source == 'compiled':
design = self.orchestrator.get_effective_site(design_id)
elif source == 'designed':
design = self.orchestrator.get_described_site(design_id)
resp.body = json.dumps(design.obj_to_simple())
except errors.DesignError:
self.error(req.context, "Design %s not found" % design_id)
self.return_error(
resp,
falcon.HTTP_404,
message="Design %s not found" % design_id,
retry=False)
示例2: on_get
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def on_get(self, req, resp, hostname):
try:
latest = req.params.get('latest', 'false').upper()
latest = True if latest == 'TRUE' else False
node_bd = self.state_manager.get_build_data(
node_name=hostname, latest=latest)
if not node_bd:
self.return_error(
resp,
falcon.HTTP_404,
message="No build data found",
retry=False)
else:
node_bd = [bd.to_dict() for bd in node_bd]
resp.status = falcon.HTTP_200
resp.body = json.dumps(node_bd)
resp.content_type = falcon.MEDIA_JSON
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: on_get
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def on_get(self, req, resp, ical_key):
"""Access the oncall calendar identified by the key.
The response is in ical format and this url is intended to be
supplied to any calendar application that can subscribe to
calendars from the internet.
"""
try:
path = self.base_url + '/api/v0/ical/' + ical_key
if req.query_string:
path += '?%s' % req.query_string
result = self.oncall_client.get(path)
except MaxRetryError as ex:
logger.error(ex)
else:
if result.status_code == 200:
resp.status = falcon.HTTP_200
resp.content_type = result.headers['Content-Type']
resp.body = result.content
return
elif 400 <= result.status_code <= 499:
resp.status = falcon.HTTP_404
return
raise falcon.HTTPInternalServerError('Internal Server Error', 'Invalid response from API')
示例4: _get_doc_from_buffer
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def _get_doc_from_buffer(self, collection_id, cleartext_secrets=False):
"""Returns the collection if it exists in the buffer.
If the buffer contains the collection, the latest
representation is what we want.
"""
# Need to guard with this check for buffer to ensure
# that the collection is not just carried through unmodified
# into the buffer, and is actually represented.
if self.is_collection_in_buffer(collection_id):
# prior check for collection in buffer means the buffer
# revision exists
buffer_id = self.get_revision_id(BUFFER)
return self.deckhand.get_docs_from_revision(
revision_id=buffer_id, bucket_id=collection_id,
cleartext_secrets=cleartext_secrets)
raise ApiError(
title='No documents to retrieve',
description=('The Shipyard buffer is empty or does not contain '
'this collection'),
status=falcon.HTTP_404,
retry=False)
示例5: _get_target_docs
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def _get_target_docs(self, collection_id, target_rev,
cleartext_secrets=False):
"""Returns the collection if it exists as committed, last_site_action
or successful_site_action.
"""
revision_id = self.get_revision_id(target_rev)
if revision_id:
return self.deckhand.get_docs_from_revision(
revision_id=revision_id, bucket_id=collection_id,
cleartext_secrets=cleartext_secrets)
raise ApiError(
title='No documents to retrieve',
description=('No collection {} for revision '
'{}'.format(collection_id, target_rev)),
status=falcon.HTTP_404,
retry=False)
示例6: _get_dag_info
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def _get_dag_info(self):
"""
returns: Dag Information
"""
# Retrieve 'dag_id' and 'dag_execution_date'
dag_id = self.action.get('dag_id')
dag_execution_date = self.action.get('dag_execution_date')
if not dag_id:
raise ApiError(
title='Dag ID Not Found!',
description='Unable to retrieve Dag ID',
status=falcon.HTTP_404)
elif not dag_execution_date:
raise ApiError(
title='Execution Date Not Found!',
description='Unable to retrieve Execution Date',
status=falcon.HTTP_404)
else:
return dag_id, dag_execution_date
示例7: _get_all_steps
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def _get_all_steps(self):
"""
returns: All steps for the action ID
"""
# Retrieve dag_id and dag_execution_date
dag_id, dag_execution_date = self._get_dag_info()
# Retrieve the action steps
steps = self._get_tasks_db(dag_id, dag_execution_date)
if not steps:
raise ApiError(
title='Steps Not Found!',
description='Unable to retrieve Information on Steps',
status=falcon.HTTP_404)
else:
LOG.debug("%s steps found for action %s",
len(steps), self.action_id)
LOG.debug("The steps for action %s are as follows:",
self.action_id)
LOG.debug(steps)
return steps
示例8: get_note_with_access_check
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def get_note_with_access_check(self, context, note_id):
"""Retrieve the note and checks user access to the note
:param context: the request context
:param note_id: the id of the note to retrieve.
:returns: the note
"""
try:
note = notes_helper.get_note(note_id)
note_type = notes_helper.get_note_assoc_id_type(note)
if note_type not in NOTE_TYPE_RBAC:
raise ApiError(
title="Unable to check permission for note type",
description=(
"Shipyard is not correctly identifying note type "
"for note {}".format(note_id)),
status=falcon.HTTP_500,
retry=False)
policy.check_auth(context, NOTE_TYPE_RBAC[note_type])
return note
except NoteNotFoundError:
raise ApiError(
title="No note found",
description=("Note {} is not found".format(note_id)),
status=falcon.HTTP_404)
示例9: get_action_validation
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def get_action_validation(self, action_id, validation_id):
"""
Interacts with the shipyard database to return the requested
validation information
:returns: the validation dicitonary object
"""
action = self.get_action_db(action_id=action_id)
if action is None:
raise ApiError(
title='Action not found',
description='Unknown action {}'.format(action_id),
status=falcon.HTTP_404)
validation = self.get_validation_db(validation_id=validation_id)
if validation is not None:
return validation
# if we didn't find it, 404
raise ApiError(
title='Validation not found',
description='Unknown validation {}'.format(validation_id),
status=falcon.HTTP_404)
示例10: test_on_get_return_no_result_and_404_when_not_found
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def test_on_get_return_no_result_and_404_when_not_found(self):
self.mock_db.get_session.return_value = None
self.mock_req.body = None
self.resource.on_get(self.mock_req, self.mock_req,
common.fake_session_0['session_id'])
self.assertIsNone(self.mock_req.body)
self.assertEqual(falcon.HTTP_404, self.mock_req.status)
示例11: test_on_get_return_no_result_and_404_when_not_found
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def test_on_get_return_no_result_and_404_when_not_found(self):
self.mock_db.get_backup.return_value = []
self.mock_req.body = None
self.resource.on_get(self.mock_req, self.mock_req,
common.fake_data_0_wrapped_backup_metadata[
'backup_id'])
self.assertIsNone(self.mock_req.body)
self.assertEqual(falcon.HTTP_404, self.mock_req.status)
示例12: test_on_get_return_no_result_and_404_when_not_found
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def test_on_get_return_no_result_and_404_when_not_found(self):
self.mock_req.body = None
self.mock_db.get_job.return_value = None
self.resource.on_get(self.mock_req, self.mock_req,
common.fake_job_0_job_id)
self.assertIsNone(self.mock_req.body)
self.assertEqual(falcon.HTTP_404, self.mock_req.status)
示例13: test_on_get_return_no_result_and_404_when_not_found
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def test_on_get_return_no_result_and_404_when_not_found(self):
self.mock_db.get_action.return_value = None
self.mock_req.body = None
self.resource.on_get(self.mock_req, self.mock_req,
common.fake_action_0['action_id'])
self.assertIsNone(self.mock_req.body)
self.assertEqual(falcon.HTTP_404, self.mock_req.status)
示例14: test_on_get_return_no_result_and_404_when_not_found
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def test_on_get_return_no_result_and_404_when_not_found(self):
self.mock_db.get_client.return_value = []
self.mock_req.body = None
self.resource.on_get(self.mock_req, self.mock_req,
common.fake_client_info_0['client_id'])
self.assertIsNone(self.mock_req.body)
self.assertEqual(falcon.HTTP_404, self.mock_req.status)
示例15: test_on_get_return_no_result_and_404_when_not_found
# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_404 [as 别名]
def test_on_get_return_no_result_and_404_when_not_found(self):
self.mock_db.get_backup.return_value = []
self.mock_req.body = None
self.resource.on_get(self.mock_req, self.mock_req,
common.fake_data_0_wrapped_backup_metadata[
'project_id'],
common.fake_data_0_wrapped_backup_metadata[
'backup_id'])
self.assertIsNone(self.mock_req.body)
self.assertEqual(falcon.HTTP_404, self.mock_req.status)