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


Python falcon.HTTP_404屬性代碼示例

本文整理匯總了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) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:26,代碼來源:designs.py

示例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) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:25,代碼來源:nodes.py

示例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') 
開發者ID:linkedin,項目名稱:iris-relay,代碼行數:27,代碼來源:app.py

示例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) 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:23,代碼來源:configdocs_helper.py

示例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) 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:20,代碼來源:configdocs_helper.py

示例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 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:22,代碼來源:action_helper.py

示例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 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:25,代碼來源:action_helper.py

示例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) 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:27,代碼來源:notedetails_api.py

示例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) 
開發者ID:airshipit,項目名稱:shipyard,代碼行數:25,代碼來源:actions_validations_id_api.py

示例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) 
開發者ID:openstack,項目名稱:freezer-api,代碼行數:9,代碼來源:test_sessions.py

示例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) 
開發者ID:openstack,項目名稱:freezer-api,代碼行數:10,代碼來源:test_backups.py

示例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) 
開發者ID:openstack,項目名稱:freezer-api,代碼行數:9,代碼來源:test_jobs.py

示例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) 
開發者ID:openstack,項目名稱:freezer-api,代碼行數:9,代碼來源:test_actions.py

示例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) 
開發者ID:openstack,項目名稱:freezer-api,代碼行數:9,代碼來源:test_clients.py

示例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) 
開發者ID:openstack,項目名稱:freezer-api,代碼行數:12,代碼來源:test_backups.py


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