当前位置: 首页>>代码示例>>Python>>正文


Python builds_logic.BuildsLogic类代码示例

本文整理汇总了Python中coprs.logic.builds_logic.BuildsLogic的典型用法代码示例。如果您正苦于以下问题:Python BuildsLogic类的具体用法?Python BuildsLogic怎么用?Python BuildsLogic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BuildsLogic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_new_build_upload

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)
开发者ID:evilkost,项目名称:copr,代码行数:26,代码来源:coprs_builds.py

示例2: webhooks_hello

def webhooks_hello(copr_id, uuid):
    # For the documentation of the data we receive see:
    # https://developer.github.com/v3/activity/events/types/#pushevent
    try:
        copr = ComplexLogic.get_copr_by_id_safe(copr_id)
    except ObjectNotFound:
        return page_not_found("Project does not exist")

    if copr.webhook_secret != uuid:
        return access_restricted("This webhook is not valid")

    try:
        request_json = flask.request.json
        clone_url = request_json["repository"]["clone_url"]
    except KeyError:
        return "Bad Request", 400
    if "commits" in request_json:
        commits = request_json["commits"]
    else:
        commits = []

    packages = PackagesLogic.get_for_webhook_rebuild(copr_id, uuid, clone_url, commits)

    for package in packages:
        BuildsLogic.rebuild_package(package)

    db.session.commit()

    return "OK", 200
开发者ID:0-T-0,项目名称:copr,代码行数:29,代码来源:webhooks_general.py

示例3: reschedule_build_chroot

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)
开发者ID:ignatenkobrain,项目名称:copr,代码行数:34,代码来源:backend_general.py

示例4: test_delete_build_basic

    def test_delete_build_basic(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        self.b1.pkgs = "http://example.com/copr-keygen-1.58-1.fc20.src.rpm"
        expected_dir = self.b1.result_dir_name
        self.db.session.add(self.b1)
        self.db.session.commit()

        expected_chroots_to_delete = set()
        for bchroot in self.b1_bc:
            expected_chroots_to_delete.add(bchroot.name)

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 1
        action = ActionsLogic.get_many().one()
        delete_data = json.loads(action.data)
        assert "chroots" in delete_data
        assert delete_data["result_dir_name"] == expected_dir
        assert expected_chroots_to_delete == set(delete_data["chroots"])

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b1.id).one()
开发者ID:0-T-0,项目名称:copr,代码行数:25,代码来源:test_builds_logic.py

示例5: factory

 def factory(**build_options):
     source_build = ComplexLogic.get_build_safe(build_id)
     BuildsLogic.create_new_from_other_build(
         flask.g.user, copr, source_build,
         chroot_names=form.selected_chroots,
         **build_options
     )
开发者ID:RadimS97,项目名称:copr,代码行数:7,代码来源:coprs_builds.py

示例6: process_new_build_pypi

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)
开发者ID:danvratil,项目名称:copr,代码行数:29,代码来源:coprs_builds.py

示例7: test_delete_build_as_admin

    def test_delete_build_as_admin(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        self.b4.pkgs = "http://example.com/copr-keygen-1.58-1.fc20.src.rpm"
        expected_dir = self.b4.result_dir_name
        for bc in self.b4_bc:
            bc.status = StatusEnum("succeeded")
            bc.ended_on = time.time()

        self.u1.admin = True

        self.db.session.add_all(self.b4_bc)
        self.db.session.add(self.b4)
        self.db.session.add(self.u1)
        self.db.session.commit()

        expected_chroots_to_delete = set()
        for bchroot in self.b4_bc:
            expected_chroots_to_delete.add(bchroot.name)

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b4)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 1
        action = ActionsLogic.get_many().one()
        delete_data = json.loads(action.data)
        assert "chroots" in delete_data
        assert delete_data["result_dir_name"] == expected_dir
        assert expected_chroots_to_delete == set(delete_data["chroots"])

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b4.id).one()
开发者ID:0-T-0,项目名称:copr,代码行数:33,代码来源:test_builds_logic.py

示例8: test_mark_as_failed

    def test_mark_as_failed(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        BuildsLogic.mark_as_failed(self.b1.id)
        BuildsLogic.mark_as_failed(self.b3.id)

        assert self.b1.status == helpers.StatusEnum("succeeded")
        assert self.b3.status == helpers.StatusEnum("failed")
        assert type(BuildsLogic.mark_as_failed(self.b3.id)) == models.Build
开发者ID:RadimS97,项目名称:copr,代码行数:7,代码来源:test_builds_logic.py

示例9: dist_git_upload_completed

def dist_git_upload_completed():
    """
    Mark BuildChroot in a Build as uploaded, which means:
        - set it to pending state
        - set BuildChroot.git_hash
        - if it's the last BuildChroot in a Build:
            - delete local srpm
    BuildChroot is identified with task_id which is build id + git branch name
        - For example: 56-f22 -> build 55, chroots fedora-22-*
    """
    result = {"updated": False}

    if "task_id" in flask.request.json:
        app.logger.debug(flask.request.data)
        task_id = flask.request.json["task_id"]
        build_chroots = BuildsLogic.get_chroots_from_dist_git_task_id(task_id)
        build = build_chroots[0].build

        # Is it OK?
        if "git_hash" in flask.request.json and "repo_name" in flask.request.json:
            git_hash = flask.request.json["git_hash"]
            repo_name = flask.request.json["repo_name"]
            pkg_name = flask.request.json["pkg_name"]
            pkg_version = flask.request.json["pkg_version"]

            # Now I need to assign a package to this build
            package = PackagesLogic.get(build.copr.id, pkg_name).first()
            if not package:
                package = PackagesLogic.add(build.copr.owner, build.copr, pkg_name)
                db.session.add(package)
                db.session.flush()

            build.package_id = package.id
            build.pkg_version = pkg_version

            for ch in build_chroots:
                ch.status = helpers.StatusEnum("pending")
                ch.git_hash = git_hash

        # Failed?
        elif "error" in flask.request.json:
            error_type = flask.request.json["error"]

            try:
                build.fail_type = helpers.FailTypeEnum(error_type)
            except KeyError:
                build.fail_type = helpers.FailTypeEnum("unknown_error")

            for ch in build_chroots:
                ch.status = helpers.StatusEnum("failed")

        # is it the last chroot?
        if not build.has_importing_chroot:
            BuildsLogic.delete_local_srpm(build)

        db.session.commit()

        result.update({"updated": True})

    return flask.jsonify(result)
开发者ID:seocam,项目名称:copr,代码行数:60,代码来源:backend_general.py

示例10: process_rebuild

def process_rebuild(copr, build_id, view, url_on_success):
    source_build = ComplexLogic.get_build_safe(build_id)
    form = forms.BuildFormRebuildFactory.create_form_cls(copr.active_chroots)()

    if form.validate_on_submit():
        try:
            build_options = {
                "enable_net": form.enable_net.data,
                "timeout": form.timeout.data,
            }

            BuildsLogic.create_new_from_other_build(
                flask.g.user, copr, source_build,
                chroot_names=form.selected_chroots,
                **build_options
            )

        except (ActionInProgressException, InsufficientRightsException) as e:
            flask.flash(str(e), "error")
            db.session.rollback()
        else:
            flask.flash("New build has been created", "success")

            db.session.commit()

        return flask.redirect(url_on_success)
    else:
        return render_add_build(copr, form, view)
开发者ID:evilkost,项目名称:copr,代码行数:28,代码来源:coprs_builds.py

示例11: test_delete_build_no_chroots_to_clean

    def test_delete_build_no_chroots_to_clean(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        for bchroot in self.b1_bc:
            bchroot.status = helpers.StatusEnum("skipped")

        self.db.session.commit()
        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()
        assert len(ActionsLogic.get_many().all()) == 0
开发者ID:0-T-0,项目名称:copr,代码行数:11,代码来源:test_builds_logic.py

示例12: test_delete_build_exceptions

    def test_delete_build_exceptions(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        self.db.session.commit()
        with pytest.raises(InsufficientRightsException):
            BuildsLogic.delete_build(self.u1, self.b4)

        self.b1_bc[0].status = "running"
        self.db.session.add(self.b1_bc[0])
        self.db.session.commit()
        with pytest.raises(ActionInProgressException):
            BuildsLogic.delete_build(self.u1, self.b1)
开发者ID:1dot75cm,项目名称:Copr,代码行数:11,代码来源:test_builds_logic.py

示例13: test_add_error_on_multiply_src

    def test_add_error_on_multiply_src(self, f_users, f_coprs,
                                          f_mock_chroots, f_db):

        params = dict(
            user=self.u1,
            pkgs="blah blah",
            copr=self.c1,
            repos="repos",
            timeout=5000)

        with pytest.raises(MalformedArgumentException):
            BuildsLogic.add(**params)
开发者ID:0-T-0,项目名称:copr,代码行数:12,代码来源:test_builds_logic.py

示例14: create_new_build

 def create_new_build():
     return BuildsLogic.create_new_from_rubygems(
         flask.g.user,
         copr,
         form.gem_name.data,
         form.selected_chroots,
     )
开发者ID:RadimS97,项目名称:copr,代码行数:7,代码来源:api_general.py

示例15: main

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))
开发者ID:0-T-0,项目名称:copr,代码行数:26,代码来源:check_for_anitya_version_updates.py


注:本文中的coprs.logic.builds_logic.BuildsLogic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。