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


Python falcon.HTTP_409属性代码示例

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


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

示例1: on_post

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

示例2: on_get

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def on_get(self, req, resp, release):
        try:

            with self.get_tiller(req, resp) as tiller:
                success = self.handle(req, release, tiller)

            if success:
                msg = {
                    'result': 'PASSED: {}'.format(release),
                    'message': 'MESSAGE: Test Pass'
                }
            else:
                msg = {
                    'result': 'FAILED: {}'.format(release),
                    'message': 'MESSAGE: Test Fail'
                }

            resp.body = json.dumps(msg)
            resp.status = falcon.HTTP_200
            resp.content_type = 'application/json'
        except LockException as e:
            self.return_error(resp, falcon.HTTP_409, message=str(e)) 
开发者ID:airshipit,项目名称:armada,代码行数:24,代码来源:test.py

示例3: add_collection

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def add_collection(self, collection_id, document_string):
        """Triggers a call to Deckhand to add a collection(bucket)
        Documents are assumed to be a string input, not a
        collection.
        Returns the id of the buffer version.
        """
        try:
            self.deckhand.put_bucket(collection_id, document_string)
        except DocumentExistsElsewhereError as deee:
            LOG.info('Deckhand has rejected this input because an included '
                     'document exists in another bucket already')
            raise ApiError(
                title='Documents may not exist in more than one collection',
                description=deee.response_message,
                status=falcon.HTTP_409)
        except DeckhandRejectedInputError as drie:
            LOG.info('Deckhand has rejected this input because: %s',
                     drie.response_message)
            raise ApiError(
                title="Document(s) invalid syntax or otherwise unsuitable",
                description=drie.response_message)
        # reset the revision dict so it regenerates.
        self.revision_dict = None
        return self.get_revision_id(BUFFER) 
开发者ID:airshipit,项目名称:shipyard,代码行数:26,代码来源:configdocs_helper.py

示例4: validate

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def validate(self):
        if self.action.get('allow_intermediate_commits'):
            LOG.debug("Intermediate commit check skipped due to user input")
        else:
            intermediate_commits = (
                self.configdocs_helper.check_intermediate_commit())
            if intermediate_commits:
                raise ApiError(
                    title='Intermediate commit detected',
                    description=(
                        'The current committed revision of documents has '
                        'other prior commits that have not been used as '
                        'part of a site action, e.g. update_site. If you '
                        'are aware and these other commits are intended, '
                        'please rerun this action with the option '
                        '`allow-intermediate-commits=True`'),
                    status=falcon.HTTP_409,
                    retry=False
                ) 
开发者ID:airshipit,项目名称:shipyard,代码行数:21,代码来源:validate_intermediate_commit.py

示例5: on_post

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def on_post(self, req, resp):
        # TODO(fmontei): Validation Content-Type is application/x-yaml.
        try:
            with self.get_tiller(req, resp) as tiller:
                return self.handle(req, resp, tiller)
        except LockException as e:
            self.return_error(resp, falcon.HTTP_409, message=str(e)) 
开发者ID:airshipit,项目名称:armada,代码行数:9,代码来源:test.py

示例6: api_lock

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def api_lock(api_lock_type):
    """
    Decorator to handle allowing a resource method to institute a lock
    based on the specified lock type.
    These locks are intended for use around methods such as on_post
    and on_get, etc...
    """
    def lock_decorator(func):
        @wraps(func)
        def func_wrapper(self, req, resp, *args, **kwargs):
            lock = ApiLock(api_lock_type,
                           req.context.external_marker,
                           req.context.user)
            try:
                lock.acquire()
                return func(self, req, resp, *args, **kwargs)
            except ApiLockAcquireError:
                raise ApiError(
                    title='Blocked by another process',
                    description=(
                        'Another process is currently blocking this request '
                        'with a lock for {}. Lock expires in not more '
                        'than {} seconds'.format(
                            lock.lock_type_name,
                            lock.expires
                        )
                    ),
                    status=falcon.HTTP_409,
                    retry=False,
                )
            finally:
                lock.release()
        return func_wrapper
    return lock_decorator 
开发者ID:airshipit,项目名称:shipyard,代码行数:36,代码来源:api_lock.py

示例7: pause_dag

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def pause_dag(self, dag_id, execution_date):
        """
        Sets the pause flag on this dag/execution
        """
        try:
            AIRFLOW_DB.pause_dag_run(
                dag_id=dag_id, execution_date=execution_date)
        except AirflowStateError as state_error:
            raise ApiError(
                title='Unable to pause action',
                description=state_error.message,
                status=falcon.HTTP_409) 
开发者ID:airshipit,项目名称:shipyard,代码行数:14,代码来源:actions_control_api.py

示例8: unpause_dag

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def unpause_dag(self, dag_id, execution_date):
        """
        Clears the pause flag on this dag/execution
        """
        try:
            AIRFLOW_DB.unpause_dag_run(
                dag_id=dag_id, execution_date=execution_date)
        except AirflowStateError as state_error:
            raise ApiError(
                title='Unable to unpause action',
                description=state_error.message,
                status=falcon.HTTP_409) 
开发者ID:airshipit,项目名称:shipyard,代码行数:14,代码来源:actions_control_api.py

示例9: commit_configdocs

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def commit_configdocs(self, helper, force, dryrun):
        """
        Attempts to commit the configdocs
        """
        if helper.is_buffer_empty():
            raise ApiError(
                title=CommitConfigDocsResource.unable_to_commmit,
                description='There are no documents in the buffer to commit',
                status=falcon.HTTP_409,
                retry=True)
        validations = helper.get_validations_for_revision(
            helper.get_revision_id(configdocs_helper.BUFFER)
        )
        if dryrun:
            validations['code'] = falcon.HTTP_200
            if 'message' in validations:
                validations['message'] = (
                    validations['message'] + ' DRYRUN')
            else:
                validations['message'] = 'DRYRUN'
        else:
            if force or validations.get('status') == 'Success':
                helper.tag_buffer(configdocs_helper.COMMITTED)
            if force and validations.get('status') == 'Failure':
                # override the status in the response
                validations['code'] = falcon.HTTP_200
                if 'message' in validations:
                    validations['message'] = (
                        validations['message'] + ' FORCED SUCCESS')
                else:
                    validations['message'] = 'FORCED SUCCESS'
        return validations 
开发者ID:airshipit,项目名称:shipyard,代码行数:34,代码来源:configdocs_api.py

示例10: on_post

# 需要导入模块: import falcon [as 别名]
# 或者: from falcon import HTTP_409 [as 别名]
def on_post(self, req, resp):
        # Load data from request and get options
        if req.content_type == 'application/x-yaml':
            data = list(self.req_yaml(req))
            if type(data[0]) is list:
                documents = list(data[0])
            else:
                documents = data
        elif req.content_type == 'application/json':
            self.logger.debug("Applying manifest based on reference.")
            req_body = self.req_json(req)
            doc_ref = req_body.get('hrefs', None)

            if not doc_ref:
                self.logger.info("Request did not contain 'hrefs'.")
                resp.status = falcon.HTTP_400
                return

            data = ReferenceResolver.resolve_reference(doc_ref)
            documents = list()
            for d in data:
                documents.extend(list(yaml.safe_load_all(d.decode())))

            if req_body.get('overrides', None):
                overrides = Override(
                    documents, overrides=req_body.get('overrides'))
                documents = overrides.update_manifests()
        else:
            self.error(
                req.context, "Unknown content-type %s" % req.content_type)
            # TODO(fmontei): Use falcon.<Relevant API Exception Class> instead.
            return self.return_error(
                resp,
                falcon.HTTP_415,
                message="Request must be in application/x-yaml"
                "or application/json")
        try:
            with self.get_tiller(req, resp) as tiller:
                msg = self.handle(req, documents, tiller)
                resp.body = json.dumps({
                    'message': msg,
                })
                resp.content_type = 'application/json'
                resp.status = falcon.HTTP_200

        except exceptions.ManifestException as e:
            self.return_error(resp, falcon.HTTP_400, message=str(e))
        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 apply manifest: {}'.format(e)
            self.error(req.context, err_message)
            self.return_error(resp, falcon.HTTP_500, message=err_message) 
开发者ID:airshipit,项目名称:armada,代码行数:56,代码来源:armada.py


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