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


Python BuildsLogic.update_state_from_dict方法代码示例

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


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

示例1: reschedule_build_chroot

# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import update_state_from_dict [as 别名]
def reschedule_build_chroot():
    response = {}
    if "build_id" in flask.request.json and "chroot" in flask.request.json:
        build = ComplexLogic.get_build_safe(flask.request.json["build_id"])
    else:
        response["result"] = "bad request"
        response["msg"] = "Request missing  `build_id` and/or `chroot`"
        return flask.jsonify(response)

    if build:
        if build.canceled:
            response["result"] = "noop"
            response["msg"] = "build was cancelled, ignoring"
        else:
            chroot = flask.request.json["chroot"]
            build_chroot = build.chroots_dict_by_name.get(chroot)
            run_statuses = set([StatusEnum("starting"), StatusEnum("running")])
            if build_chroot and build_chroot.status in run_statuses:
                log.info("rescheduling build {} chroot: {}".format(build.id, build_chroot.name))
                BuildsLogic.update_state_from_dict(build, {
                    "chroot": chroot,
                    "status": StatusEnum("pending")
                })
                db.session.commit()
                response["result"] = "done"
            else:
                response["result"] = "noop"
                response["msg"] = "build is not in running states, ignoring"

    else:
        response["result"] = "noop"
        response["msg"] = "Build {} wasn't found".format(flask.request.json["build_id"])

    return flask.jsonify(response)
开发者ID:ignatenkobrain,项目名称:copr,代码行数:36,代码来源:backend_general.py

示例2: starting_build

# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import update_state_from_dict [as 别名]
def starting_build():
    """
    Check if the build is not cancelled and set it to running state
    """

    result = {"can_start": False}

    if "build_id" in flask.request.json and "chroot" in flask.request.json:
        build = ComplexLogic.get_build_safe(flask.request.json["build_id"])
        chroot = flask.request.json.get("chroot")

        if build and chroot and not build.canceled:
            log.info("mark build {} chroot {} as starting".format(build.id, chroot))
            BuildsLogic.update_state_from_dict(build, {
                "chroot": chroot,
                "status": StatusEnum("starting")
            })
            db.session.commit()
            result["can_start"] = True

    return flask.jsonify(result)
开发者ID:ignatenkobrain,项目名称:copr,代码行数:23,代码来源:backend_general.py


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