本文整理汇总了Python中coprs.logic.complex_logic.ComplexLogic.get_group_by_name_safe方法的典型用法代码示例。如果您正苦于以下问题:Python ComplexLogic.get_group_by_name_safe方法的具体用法?Python ComplexLogic.get_group_by_name_safe怎么用?Python ComplexLogic.get_group_by_name_safe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coprs.logic.complex_logic.ComplexLogic
的用法示例。
在下文中一共展示了ComplexLogic.get_group_by_name_safe方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: group_copr_new
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import get_group_by_name_safe [as 别名]
def group_copr_new(group_name):
group = ComplexLogic.get_group_by_name_safe(group_name)
form = forms.CoprFormFactory.create_form_cls(group=group)()
if form.validate_on_submit():
copr = coprs_logic.CoprsLogic.add(
flask.g.user,
name=form.name.data,
homepage=form.homepage.data,
contact=form.contact.data,
repos=form.repos.data.replace("\n", " "),
selected_chroots=form.selected_chroots,
description=form.description.data,
instructions=form.instructions.data,
disable_createrepo=form.disable_createrepo.data,
build_enable_net=form.build_enable_net.data,
group=group
)
db.session.add(copr)
db.session.commit()
after_the_project_creation(copr, form)
return flask.redirect(url_for_copr_details(copr))
else:
return flask.render_template("coprs/group_add.html", form=form, group=group)
示例2: list_projects_by_group
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import get_group_by_name_safe [as 别名]
def list_projects_by_group(group_name, page=1):
group = ComplexLogic.get_group_by_name_safe(group_name)
query = CoprsLogic.get_multiple_by_group_id(group.id)
paginator = Paginator(query, query.count(), page)
coprs = paginator.sliced_query
return render_template(
"coprs/show/group.html",
user=flask.g.user,
coprs=coprs,
paginator=paginator,
tasks_info=ComplexLogic.get_queues_size(),
group=group
)
示例3: group_copr_add
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import get_group_by_name_safe [as 别名]
def group_copr_add(group_name):
group = ComplexLogic.get_group_by_name_safe(group_name)
form = forms.CoprFormFactory.create_form_cls()()
return flask.render_template(
"coprs/group_add.html", form=form, group=group)
示例4: group_coprs_migration_report
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import get_group_by_name_safe [as 别名]
def group_coprs_migration_report(group_name=None):
group = ComplexLogic.get_group_by_name_safe(group_name)
coprs = CoprsLogic.get_multiple_by_group_id(group.id)
return render_migration_report(coprs, group=group)
示例5: api_new_copr
# 需要导入模块: from coprs.logic.complex_logic import ComplexLogic [as 别名]
# 或者: from coprs.logic.complex_logic.ComplexLogic import get_group_by_name_safe [as 别名]
def api_new_copr(username):
"""
Receive information from the user on how to create its new copr,
check their validity and create the corresponding copr.
:arg name: the name of the copr to add
:arg chroots: a comma separated list of chroots to use
:kwarg repos: a comma separated list of repository that this copr
can use.
:kwarg initial_pkgs: a comma separated list of initial packages to
build in this new copr
"""
form = forms.CoprFormFactory.create_form_cls()(csrf_enabled=False)
# are there any arguments in POST which our form doesn't know?
# TODO: don't use WTFform for parsing and validation here
if any([post_key not in form.__dict__.keys()
for post_key in flask.request.form.keys()]):
raise LegacyApiError("Unknown arguments passed (non-existing chroot probably)")
elif form.validate_on_submit():
infos = []
group = ComplexLogic.get_group_by_name_safe(username[1:]) if username[0] == "@" else None
try:
copr = CoprsLogic.add(
name=form.name.data.strip(),
repos=" ".join(form.repos.data.split()),
user=flask.g.user,
selected_chroots=form.selected_chroots,
description=form.description.data,
instructions=form.instructions.data,
check_for_duplicates=False,
auto_createrepo=True,
group=group,
)
infos.append("New project was successfully created.")
if form.initial_pkgs.data:
pkgs = form.initial_pkgs.data.split()
for pkg in pkgs:
builds_logic.BuildsLogic.add(
user=flask.g.user,
pkgs=pkg,
copr=copr)
infos.append("Initial packages were successfully "
"submitted for building.")
output = {"output": "ok", "message": "\n".join(infos)}
db.session.commit()
except exceptions.DuplicateException as err:
db.session.rollback()
raise LegacyApiError(str(err))
else:
errormsg = "Validation error\n"
if form.errors:
for field, emsgs in form.errors.items():
errormsg += "- {0}: {1}\n".format(field, "\n".join(emsgs))
errormsg = errormsg.replace('"', "'")
raise LegacyApiError(errormsg)
return flask.jsonify(output)