本文整理汇总了Python中coprs.logic.complex_logic.ComplexLogic.fork_copr方法的典型用法代码示例。如果您正苦于以下问题:Python ComplexLogic.fork_copr方法的具体用法?Python ComplexLogic.fork_copr怎么用?Python ComplexLogic.fork_copr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coprs.logic.complex_logic.ComplexLogic
的用法示例。
在下文中一共展示了ComplexLogic.fork_copr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fork_copr_sends_actions
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import fork_copr [as 别名]
def test_fork_copr_sends_actions(self, mc_flask_g, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
mc_flask_g.user.name = self.u2.name
fc1, created = ComplexLogic.fork_copr(self.c1, self.u2, u"dstname")
self.db.session.commit()
actions = ActionsLogic.get_many(ActionTypeEnum("gen_gpg_key")).all()
assert len(actions) == 1
data = json.loads(actions[0].data)
assert data["username"] == self.u2.name
assert data["projectname"] == "dstname"
actions = ActionsLogic.get_many(ActionTypeEnum("fork")).all()
assert len(actions) == 1
data = json.loads(actions[0].data)
assert data["user"] == self.u2.name
assert data["copr"] == "dstname"
last_build, forked_build = self.c1.packages[0].builds[1], fc1.builds[0]
assert data["builds_map"] == {str(forked_build.id): str(last_build.result_dir_name)}
示例2: copr_fork_post
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import fork_copr [as 别名]
def copr_fork_post(copr):
form = forms.CoprForkFormFactory.create_form_cls(copr=copr, user=flask.g.user, groups=flask.g.user.user_groups)()
if form.validate_on_submit():
dstgroup = ([g for g in flask.g.user.user_groups if g.at_name == form.owner.data] or [None])[0]
if flask.g.user.name != form.owner.data and not dstgroup:
return generic_error("There is no such group: {}".format(form.owner.data))
fcopr = CoprsLogic.get_by_group_id(dstgroup.id, form.name.data).first() if dstgroup \
else CoprsLogic.filter_without_group_projects(CoprsLogic.get(flask.g.user.name, form.name.data)).first()
if not fcopr:
fcopr = ComplexLogic.fork_copr(copr, flask.g.user, dstname=form.name.data, dstgroup=dstgroup)
db.session.commit()
flask.flash("Forking project {} for you into {}. Please be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))
return flask.redirect(url_for_copr_details(fcopr))
return render_copr_fork(copr, form)
示例3: copr_fork_post
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import fork_copr [as 别名]
def copr_fork_post(copr):
form = forms.CoprForkFormFactory.create_form_cls(copr=copr, user=flask.g.user, groups=flask.g.user.user_groups)()
if form.validate_on_submit():
dstgroup = ([g for g in flask.g.user.user_groups if g.at_name == form.owner.data] or [None])[0]
if flask.g.user.name != form.owner.data and not dstgroup:
return generic_error("There is no such group: {}".format(form.owner.data))
fcopr, created = ComplexLogic.fork_copr(copr, flask.g.user, dstname=form.name.data, dstgroup=dstgroup)
if created:
msg = ("Forking project {} for you into {}. Please be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))
elif not created and form.confirm.data == True:
msg = ("Updating packages in {} from {}. Please be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))
else:
return render_copr_fork(copr, form, confirm=True)
db.session.commit()
flask.flash(msg)
return flask.redirect(url_for_copr_details(fcopr))
return render_copr_fork(copr, form)
示例4: api_copr_fork
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import fork_copr [as 别名]
def api_copr_fork(copr):
""" Fork the project and builds in it
"""
form = forms.CoprForkFormFactory\
.create_form_cls(copr=copr, user=flask.g.user, groups=flask.g.user.user_groups)(csrf_enabled=False)
# I have no idea why there is by default form.confirm.data equal to True
form.confirm.data = flask.request.form["confirm"] == "True"
if form.validate_on_submit() and copr:
try:
dstgroup = ([g for g in flask.g.user.user_groups if g.at_name == form.owner.data] or [None])[0]
if flask.g.user.name != form.owner.data and not dstgroup:
return LegacyApiError("There is no such group: {}".format(form.owner.data))
fcopr, created = ComplexLogic.fork_copr(copr, flask.g.user, dstname=form.name.data, dstgroup=dstgroup)
if created:
msg = ("Forking project {} for you into {}.\nPlease be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))
elif not created and form.confirm.data == True:
msg = ("Updating packages in {} from {}.\nPlease be aware that it may take a few minutes "
"to duplicate a backend data.".format(copr.full_name, fcopr.full_name))
else:
raise LegacyApiError("You are about to fork into existing project: {}\n"
"Please use --confirm if you really want to do this".format(fcopr.full_name))
output = {"output": "ok", "message": msg}
db.session.commit()
except (exceptions.ActionInProgressException,
exceptions.InsufficientRightsException) as err:
db.session.rollback()
raise LegacyApiError(str(err))
else:
raise LegacyApiError("Invalid request")
return flask.jsonify(output)