Example #1
0
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)
Example #2
0
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)
Example #3
0
 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
     )
Example #4
0
 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)
Example #5
0
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)
Example #6
0
 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,
     )
Example #7
0
 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,
     )
Example #8
0
def copr_new_build_upload(copr):

    form = forms.BuildFormUploadFactory.create_form_cls(
        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)