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


Python PackagesLogic.reset_package方法代码示例

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


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

示例1: process_save_package

# 需要导入模块: from coprs.logic.packages_logic import PackagesLogic [as 别名]
# 或者: from coprs.logic.packages_logic.PackagesLogic import reset_package [as 别名]
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,代码行数:52,代码来源:coprs_packages.py

示例2: copr_reset_package

# 需要导入模块: from coprs.logic.packages_logic import PackagesLogic [as 别名]
# 或者: from coprs.logic.packages_logic.PackagesLogic import reset_package [as 别名]
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,代码行数:19,代码来源:api_general.py


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