本文整理汇总了Python中coprs.logic.builds_logic.BuildsLogic.create_new_from_upload方法的典型用法代码示例。如果您正苦于以下问题:Python BuildsLogic.create_new_from_upload方法的具体用法?Python BuildsLogic.create_new_from_upload怎么用?Python BuildsLogic.create_new_from_upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coprs.logic.builds_logic.BuildsLogic
的用法示例。
在下文中一共展示了BuildsLogic.create_new_from_upload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_new_build_upload
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import create_new_from_upload [as 别名]
def process_new_build_upload(copr, add_view, url_on_success):
form = forms.BuildFormUploadFactory.create_form_cls(copr.active_chroots)()
if form.validate_on_submit():
build_options = {
"enable_net": form.enable_net.data,
"timeout": form.timeout.data,
}
try:
BuildsLogic.create_new_from_upload(
flask.g.user, copr,
f_uploader=lambda path: form.pkgs.data.save(path),
orig_filename=form.pkgs.data.filename,
chroot_names=form.selected_chroots,
**build_options
)
db.session.commit()
except (ActionInProgressException, InsufficientRightsException) as e:
db.session.rollback()
flask.flash(str(e), "error")
else:
flask.flash("New build has been created.")
return flask.redirect(url_on_success)
else:
return render_add_build_upload(copr, form, add_view)
示例2: factory
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import create_new_from_upload [as 别名]
def factory(**build_options):
BuildsLogic.create_new_from_upload(
flask.g.user, copr,
f_uploader=lambda path: form.pkgs.data.save(path),
orig_filename=form.pkgs.data.filename,
chroot_names=form.selected_chroots,
**build_options
)
示例3: copr_new_build_upload
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import create_new_from_upload [as 别名]
def copr_new_build_upload(copr):
form = forms.BuildFormUploadFactory(copr.active_chroots)(csrf_enabled=False)
# are there any arguments in POST which our form doesn't know?
if any([post_key not in form.__dict__.keys()
for post_key in flask.request.form.keys()]):
raise LegacyApiError("Unknown arguments passed (non-existing chroot probably)")
if not form.validate_on_submit():
raise LegacyApiError("Invalid request: bad request parameters")
filename = secure_filename(form.pkgs.data.filename)
# create a new build
try:
build = BuildsLogic.create_new_from_upload(
flask.g.user, copr,
f_uploader=lambda path: form.pkgs.data.save(path),
orig_filename=filename,
chroot_names=form.selected_chroots,
)
db.session.commit()
except (ActionInProgressException, InsufficientRightsException) as e:
raise LegacyApiError("Invalid request: {}".format(e))
output = {"output": "ok",
"ids": [build.id],
"message": "Build was added to {0}.".format(copr.name)}
return flask.jsonify(output)
示例4: create_new_build
# 需要导入模块: from coprs.logic.builds_logic import BuildsLogic [as 别名]
# 或者: from coprs.logic.builds_logic.BuildsLogic import create_new_from_upload [as 别名]
def create_new_build():
return BuildsLogic.create_new_from_upload(
flask.g.user, copr,
f_uploader=lambda path: form.pkgs.data.save(path),
orig_filename=secure_filename(form.pkgs.data.filename),
chroot_names=form.selected_chroots,
)