예제 #1
0
def process_new_build_pypi(copr, add_view, url_on_success):
    form = forms.BuildFormPyPIFactory(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_pypi(
                flask.g.user,
                copr,
                form.pypi_package_name.data,
                form.pypi_package_version.data,
                form.python_versions.data,
                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_pypi(copr, form, add_view)
예제 #2
0
 def factory(**build_options):
     BuildsLogic.create_new_from_pypi(flask.g.user, copr,
                                      form.pypi_package_name.data,
                                      form.pypi_package_version.data,
                                      form.python_versions.data,
                                      form.selected_chroots,
                                      **build_options)
예제 #3
0
 def factory(**build_options):
     BuildsLogic.create_new_from_pypi(
         flask.g.user,
         copr,
         form.pypi_package_name.data,
         form.pypi_package_version.data,
         form.python_versions.data,
         form.selected_chroots,
         **build_options
     )
예제 #4
0
 def build(self, copr, new_updated_version):
     return BuildsLogic.create_new_from_pypi(copr.user,
                                             copr,
                                             self.name,
                                             new_updated_version,
                                             self.python_versions,
                                             chroot_names=None)
예제 #5
0
def copr_new_build_pypi(copr):
    form = forms.BuildFormPyPIFactory(copr.active_chroots)(csrf_enabled=False)

    # TODO: automatically prepopulate all form fields with their defaults
    if not form.python_versions.data:
        form.python_versions.data = form.python_versions.default

    # 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: {0}".format(form.errors))

    # create a new build
    try:
        build = BuildsLogic.create_new_from_pypi(
            flask.g.user,
            copr,
            form.pypi_package_name.data,
            form.pypi_package_version.data,
            form.python_versions.data,
            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)
def main():
    updated_packages = get_updated_packages(get_updates_messages())
    loginfo('Updated packages according to datagrepper: {0}'.format(updated_packages))

    for row in get_copr_package_info_rows():
        source_json = json.loads(row.source_json)
        source_package_name = source_json['pypi_package_name'].lower()
        source_python_versions = source_json['python_versions']
        latest_build_version = row.pkg_version
        loginfo('candidate package for rebuild: {0}, package_id: {1}, copr_id: {2}'.format(source_package_name, row.package_id, row.copr_id))
        if source_package_name in updated_packages:
            new_updated_version = updated_packages[source_package_name]
            logdebug('source_package_name: {0}, latest_build_version: {1}, new_updated_version {2}'.format(source_package_name, latest_build_version, new_updated_version))
            if not latest_build_version or not re.match(new_updated_version, latest_build_version): # if the last build's package version is "different" from new remote package version, rebuild
                try:
                    copr = CoprsLogic.get_by_id(row.copr_id)[0]
                except Exception as e:
                    logexception(e)
                    continue
                if args.backend.lower() == 'pypi':
                    loginfo('Launching pypi build for package of source name: {0}, package_id: {1}, copr_id: {2}, user_id: {3}'.format(source_package_name, row.package_id, copr.id, copr.user.id))
                    build = BuildsLogic.create_new_from_pypi(copr.user, copr, source_package_name, new_updated_version, source_python_versions, chroot_names=None)
                else:
                    raise Exception('Unsupported backend {0} passed as command-line argument'.format(args.backend))
                db.session.commit()
                loginfo('Launched build id {0}'.format(build.id))
예제 #7
0
 def create_new_build():
     return BuildsLogic.create_new_from_pypi(
         flask.g.user,
         copr,
         form.pypi_package_name.data,
         form.pypi_package_version.data,
         form.python_versions.data,
         form.selected_chroots,
     )
예제 #8
0
 def create_new_build():
     return BuildsLogic.create_new_from_pypi(
         flask.g.user,
         copr,
         form.pypi_package_name.data,
         form.pypi_package_version.data,
         form.python_versions.data,
         form.selected_chroots,
     )
예제 #9
0
 def create_new_build():
     return BuildsLogic.create_new_from_pypi(
         flask.g.user,
         copr,
         form.pypi_package_name.data,
         form.pypi_package_version.data,
         form.spec_template.data,
         form.python_versions.data,
         form.selected_chroots,
         background=form.background.data,
         copr_dirname=form.project_dirname.data,
     )
 def build(self, copr, new_updated_version):
     return BuildsLogic.create_new_from_pypi(copr.user, copr, self.name, new_updated_version, self.python_versions, chroot_names=None)