本文整理汇总了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
示例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