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


Python packages_logic.PackagesLogic类代码示例

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


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

示例1: 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

示例2: copr_delete_package

def copr_delete_package(copr, package_id):
    package = ComplexLogic.get_package_by_id_safe(package_id)

    try:
        PackagesLogic.delete_package(flask.g.user, package)
    except (InsufficientRightsException, ActionInProgressException) as e:
        flask.flash(str(e), "error")
    else:
        db.session.commit()
        flask.flash("Package has been deleted successfully.", "success")

    return flask.redirect(helpers.copr_url("coprs_ns.copr_packages", copr))
开发者ID:0-T-0,项目名称:copr,代码行数:12,代码来源:coprs_packages.py

示例3: process_save_package

def process_save_package(copr, source_type_text, package_name, view, view_method, url_on_success):
    form = forms.get_package_form_cls_by_source_type_text(source_type_text)()

    if "reset" in flask.request.form:
        try:
            package = PackagesLogic.get(copr.id, package_name)[0]
        except IndexError:
            flask.flash("Package {package_name} does not exist in copr {copr}.".format(package_name, copr.full_name))
            return flask.redirect(url_on_success) # should be url_on_fail

        try:
            PackagesLogic.reset_package(flask.g.user, package)
            db.session.commit()
        except InsufficientRightsException as e:
            flask.flash(str(e))
            return flask.redirect(url_on_success) # should be url_on_fail

        flask.flash("Package default source successfully reset.")
        return flask.redirect(url_on_success)

    if form.validate_on_submit():
        try:
            if package_name:
                package = PackagesLogic.get(copr.id, package_name)[0]
            else:
                package = PackagesLogic.add(flask.app.g.user, copr, form.package_name.data)

            package.source_type = helpers.BuildSourceEnum(source_type_text)
            package.webhook_rebuild = form.webhook_rebuild.data
            package.source_json = form.source_json

            db.session.add(package)
            db.session.commit()
        except (InsufficientRightsException, IndexError) as e:
            db.session.rollback()
            flask.flash(str(e), "error")
        else:
            flask.flash("Package successfully saved" if package_name else "New package has been created.")

        return flask.redirect(url_on_success)

    kwargs = {
        "coprname": copr.name,
        "package_name": package_name,
        "source_type_text": source_type_text,
        "form": form,
    }

    kwargs.update({"group_name": copr.group.name} if copr.is_a_group_project else {"username": copr.user.name})
    return view_method(**kwargs)
开发者ID:bowlofeggs,项目名称:copr,代码行数:50,代码来源:coprs_packages.py

示例4: process_save_package

def process_save_package(copr, package_name, view, view_method, url_on_success):
    if flask.request.form["source_type"] == "git_and_tito":
        form = forms.PackageFormTito()
    elif flask.request.form["source_type"] == "mock_scm":
        form = forms.PackageFormMock()
    elif flask.request.form["source_type"] == "pypi":
        form = forms.PackageFormPyPI()
    else:
        raise Exception("Wrong source type")

    if form.validate_on_submit():
        if package_name:
            package = PackagesLogic.get(copr.id, package_name).first()
        else:
            package = PackagesLogic.add(flask.app.g.user, copr, form.package_name.data)

        package.source_type = helpers.BuildSourceEnum(form.source_type.data)
        package.webhook_rebuild = form.webhook_rebuild.data

        if package.source_type == helpers.BuildSourceEnum("git_and_tito"):
            package.source_json = json.dumps({
                "git_url": form.git_url.data,
                "git_branch": form.git_branch.data,
                "git_dir": form.git_directory.data,
                "tito_test": form.tito_test.data})
        elif package.source_type == helpers.BuildSourceEnum("mock_scm"):
            package.source_json = json.dumps({
                "scm_type": form.scm_type.data,
                "scm_url": form.scm_url.data,
                "scm_branch": form.scm_branch.data,
                "spec": form.spec.data})
        elif package.source_type == helpers.BuildSourceEnum("pypi"):
            package.source_json = json.dumps({
                "pypi_package_name": form.pypi_package_name.data,
                "python_versions": form.python_versions.data})

        try:
            db.session.add(package)
            db.session.commit()
        except (ActionInProgressException, InsufficientRightsException) as e:
            db.session.rollback()
            flask.flash(str(e), "error")
        else:
            flask.flash("Package successfully saved" if package_name else "New package has been created.")

        return flask.redirect(url_on_success)

    return view_method(username=copr.owner.name, coprname=copr.name,
                       package_name=package_name, source_type=form.source_type.data, form=form)
开发者ID:danvratil,项目名称:copr,代码行数:49,代码来源:coprs_packages.py

示例5: process_package_edit

def process_package_edit(copr, package_name, view):
    if request.form["source_type"] == "git_and_tito":
        form = forms.PackageFormTitoFactory
        form_var = "form_tito"
    elif request.form["source_type"] == "mock_scm":
        form = forms.PackageFormMockFactory
        form_var = "form_mock"
    else:
        raise Exception("Wrong source type")
    form = form.create_form_cls()()

    if form.validate_on_submit():
        package = PackagesLogic.get(copr.id, package_name).first()
        package.source_type = helpers.BuildSourceEnum(form.source_type.data)

        if package.source_type == helpers.BuildSourceEnum("git_and_tito"):
            package.source_json = json.dumps({
                "git_url": form.git_url.data,
                "git_branch": form.git_branch.data,
                "git_dir": form.git_directory.data,
                "tito_test": form.tito_test.data})
        elif package.source_type == helpers.BuildSourceEnum("mock_scm"):
            package.source_json = json.dumps({
                "scm_type": form.scm_type.data,
                "scm_url": form.scm_url.data,
                "scm_branch": form.scm_branch.data,
                "spec": form.spec.data})

        db.session.add(package)
        db.session.commit()

    return render_package_edit(copr, package_name, view, **{form_var: form})
开发者ID:evilkost,项目名称:copr,代码行数:32,代码来源:coprs_builds.py

示例6: get_package_safe

 def get_package_safe(copr, package_name):
     try:
         return PackagesLogic.get(copr.id, package_name).one()
     except sqlalchemy.orm.exc.NoResultFound:
         raise ObjectNotFound(
             message="Package {} in the copr {} does not exist."
             .format(package_name, copr))
开发者ID:tkdchen,项目名称:copr,代码行数:7,代码来源:complex_logic.py

示例7: fork_package

 def fork_package(self, package, fcopr):
     fpackage = PackagesLogic.get(fcopr.id, package.name).first()
     if not fpackage:
         fpackage = self.create_object(models.Package, package, exclude=["id", "copr_id"])
         fpackage.copr = fcopr
         db.session.add(fpackage)
     return fpackage
开发者ID:0-T-0,项目名称:copr,代码行数:7,代码来源:complex_logic.py

示例8: process_package_add_or_edit

def process_package_add_or_edit(copr, source_type, package=None):
    try:
        form = forms.get_package_form_cls_by_source_type(source_type)(csrf_enabled=False)
    except UnknownSourceTypeException:
        raise LegacyApiError("Unsupported package source type {source_type}".format(source_type=source_type))

    if form.validate_on_submit():
        if not package:
            try:
                package = PackagesLogic.add(flask.app.g.user, copr, form.package_name.data)
            except InsufficientRightsException:
                raise LegacyApiError("Insufficient permissions.")
            except DuplicateException:
                raise LegacyApiError("Package {0} already exists in copr {1}.".format(form.package_name.data, copr.full_name))

        package.source_type = helpers.BuildSourceEnum(form.source_type.data)
        package.webhook_rebuild = form.webhook_rebuild.data
        package.source_json = form.source_json

        db.session.add(package)
        db.session.commit()
    else:
        raise LegacyApiError(form.errors)

    return flask.jsonify({
        "output": "ok",
        "message": "Create or edit operation was successful.",
        "package": package.to_dict(),
    })
开发者ID:RadimS97,项目名称:copr,代码行数:29,代码来源:api_general.py

示例9: 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

示例10: copy_data

def copy_data(cp):
    for model in mods:
        cp.copy_objects(model)

    for copr in all_coprs():
        for package in PackagesLogic.get_all(copr.id):
            cp.copy_package(package)
            cp.copy_build(package.last_build(successful=True))
开发者ID:0-T-0,项目名称:copr,代码行数:8,代码来源:migrate-copr.py

示例11: copr_get_package

def copr_get_package(copr, package_name):
    try:
        package = PackagesLogic.get(copr.id, package_name)[0]
    except IndexError:
        raise LegacyApiError("No package with name {name} in copr {copr}".format(name=package_name, copr=copr.name))

    params = get_package_record_params()
    return flask.jsonify({'package': package.to_dict(**params)})
开发者ID:bowlofeggs,项目名称:copr,代码行数:8,代码来源:api_general.py

示例12: copr_reset_package

def copr_reset_package(copr, package_name):
    try:
        package = PackagesLogic.get(copr.id, package_name)[0]
    except IndexError:
        raise LegacyApiError("No package with name {name} in copr {copr}".format(name=package_name, copr=copr.name))

    try:
        PackagesLogic.reset_package(flask.g.user, package)
        db.session.commit()
    except InsufficientRightsException as e:
        raise LegacyApiError(str(e))

    return flask.jsonify({
        "output": "ok",
        "message": "Package's default source was successfully reseted.",
        'package': package.to_dict(),
    })
开发者ID:RadimS97,项目名称:copr,代码行数:17,代码来源:api_general.py

示例13: copr_build_package

def copr_build_package(copr, package_name):
    form = forms.BuildFormRebuildFactory.create_form_cls(copr.active_chroots)(csrf_enabled=False)

    try:
        package = PackagesLogic.get(copr.id, package_name)[0]
    except IndexError:
        raise LegacyApiError("No package with name {name} in copr {copr}".format(name=package_name, copr=copr.name))

    if form.validate_on_submit():
        try:
            build = PackagesLogic.build_package(flask.g.user, copr, package, form.selected_chroots, **form.data)
            db.session.commit()
        except (InsufficientRightsException, ActionInProgressException, NoPackageSourceException) as e:
            raise LegacyApiError(str(e))
    else:
        raise LegacyApiError(form.errors)

    return flask.jsonify({
        "output": "ok",
        "ids": [build.id],
        "message": "Build was added to {0}.".format(copr.name)
    })
开发者ID:bowlofeggs,项目名称:copr,代码行数:22,代码来源:api_general.py

示例14: webhooks_hello

def webhooks_hello(copr_id, uuid):
    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

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

    for package in packages:
        BuildsLogic.rebuild_package(package)

    db.session.commit()

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

示例15: copr_packages

def copr_packages(copr):
    packages = PackagesLogic.get_all(copr.id)
    return flask.render_template("coprs/detail/packages.html", packages=packages, copr=copr, empty_build=Build())
开发者ID:danvratil,项目名称:copr,代码行数:3,代码来源:coprs_packages.py


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