當前位置: 首頁>>代碼示例>>Python>>正文


Python ActionsLogic.send_fork_copr方法代碼示例

本文整理匯總了Python中coprs.logic.actions_logic.ActionsLogic.send_fork_copr方法的典型用法代碼示例。如果您正苦於以下問題:Python ActionsLogic.send_fork_copr方法的具體用法?Python ActionsLogic.send_fork_copr怎麽用?Python ActionsLogic.send_fork_copr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在coprs.logic.actions_logic.ActionsLogic的用法示例。


在下文中一共展示了ActionsLogic.send_fork_copr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fork_copr

# 需要導入模塊: from coprs.logic.actions_logic import ActionsLogic [as 別名]
# 或者: from coprs.logic.actions_logic.ActionsLogic import send_fork_copr [as 別名]
    def fork_copr(cls, copr, user, dstname, dstgroup=None):
        if dstgroup and not user.can_build_in_group(dstgroup):
            raise exceptions.InsufficientRightsException(
                "Only members may create projects in the particular groups.")

        fcopr = CoprsLogic.get_by_group_id(dstgroup.id, dstname).first() if dstgroup \
            else CoprsLogic.filter_without_group_projects(CoprsLogic.get(flask.g.user.name, dstname)).first()

        if fcopr:
            raise exceptions.DuplicateException("You already have {}/{} project".format(user.name, copr.name))

        # @TODO Move outside and properly test it
        def create_object(clazz, from_object, exclude=list()):
            arguments = {}
            for name, column in from_object.__mapper__.columns.items():
                if not name in exclude:
                    arguments[name] = getattr(from_object, name)
            return clazz(**arguments)

        fcopr = create_object(models.Copr, copr, exclude=["id", "group_id"])
        fcopr.forked_from_id = copr.id
        fcopr.owner = user
        fcopr.owner_id = user.id
        if dstname:
            fcopr.name = dstname
        if dstgroup:
            fcopr.group = dstgroup
            fcopr.group_id = dstgroup.id

        for chroot in list(copr.copr_chroots):
            CoprChrootsLogic.create_chroot(user, fcopr, chroot.mock_chroot, chroot.buildroot_pkgs,
                                           comps=chroot.comps, comps_name=chroot.comps_name)

        builds_map = {}
        for package in copr.packages:
            fpackage = create_object(models.Package, package, exclude=["id", "copr_id"])
            fpackage.copr = fcopr
            db.session.add(fpackage)

            build = package.last_build()
            if not build:
                continue

            fbuild = create_object(models.Build, build, exclude=["id", "copr_id", "package_id"])
            fbuild.copr = fcopr
            fbuild.package = fpackage
            fbuild.build_chroots = [create_object(models.BuildChroot, c, exclude=["id"]) for c in build.build_chroots]
            db.session.add(fbuild)
            builds_map[fbuild.id] = build.id

        ActionsLogic.send_fork_copr(copr, fcopr, builds_map)
        db.session.add(fcopr)
        return fcopr
開發者ID:tkdchen,項目名稱:copr,代碼行數:55,代碼來源:complex_logic.py

示例2: fork_copr

# 需要導入模塊: from coprs.logic.actions_logic import ActionsLogic [as 別名]
# 或者: from coprs.logic.actions_logic.ActionsLogic import send_fork_copr [as 別名]
    def fork_copr(cls, copr, user, dstname, dstgroup=None):
        forking = ProjectForking(user, dstgroup)
        fcopr = forking.fork_copr(copr, dstname)
        created = fcopr in db.session.new

        if fcopr.full_name == copr.full_name:
            raise exceptions.DuplicateException("Source project should not be same as destination")

        builds_map = {}
        for package in copr.packages:
            fpackage = forking.fork_package(package, fcopr)
            build = package.last_build()
            if not build:
                continue

            fbuild = forking.fork_build(build, fcopr, fpackage)
            builds_map[fbuild.id] = build.result_dir_name

        ActionsLogic.send_fork_copr(copr, fcopr, builds_map)
        return fcopr, created
開發者ID:lubomir,項目名稱:copr,代碼行數:22,代碼來源:complex_logic.py


注:本文中的coprs.logic.actions_logic.ActionsLogic.send_fork_copr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。