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