本文整理汇总了Python中models.Build.get_from_id方法的典型用法代码示例。如果您正苦于以下问题:Python Build.get_from_id方法的具体用法?Python Build.get_from_id怎么用?Python Build.get_from_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Build
的用法示例。
在下文中一共展示了Build.get_from_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_build
# 需要导入模块: from models import Build [as 别名]
# 或者: from models.Build import get_from_id [as 别名]
def get_build(build_id):
#looks up the build by its id in the database
#the variable build_id is passed in the url
try:
build = Build.get_from_id(ObjectId(build_id))
except Exception:
return jsonify(error="Invalid Build ID")
if build is None:
return jsonify(error="Invalid Build ID")
#looks at the status of the build
#returns jsonify(status of build)
return (build.to_json(), 200)
示例2: rebuild
# 需要导入模块: from models import Build [as 别名]
# 或者: from models.Build import get_from_id [as 别名]
def rebuild():
#takes build ID as parameter
id = request.form.get('build_id', None)
try:
build = Build.get_from_id(ObjectId(id))
except Exception:
return jsonify(error="Invalid Build ID")
if build is None:
return jsonify(error="Invalid Build ID")
#looks up a build by that ID
#rebuilds build to see if it fails new tests
api.queue.add_build(build)
if (api.worker is None or api.worker.current_build is None):
api.worker = WorkerThread(api.queue, api.config, connection)
api.worker.start()
return jsonify(success=True, id=id)