本文整理匯總了Python中pagure.LOG.error方法的典型用法代碼示例。如果您正苦於以下問題:Python LOG.error方法的具體用法?Python LOG.error怎麽用?Python LOG.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pagure.LOG
的用法示例。
在下文中一共展示了LOG.error方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: edit_comment_issue
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def edit_comment_issue(repo, issueid, commentid, username=None):
"""Edit comment of an issue
"""
is_js = flask.request.args.get('js', False)
project = pagure.lib.get_project(SESSION, repo, user=username)
if not project:
flask.abort(404, 'Project not found')
if not project.settings.get('issue_tracker', True):
flask.abort(404, 'No issue tracker found for this project')
issue = pagure.lib.search_issues(SESSION, project, issueid=issueid)
if issue is None or issue.project != project:
flask.abort(404, 'Issue not found')
comment = pagure.lib.get_issue_comment(
SESSION, issue.uid, commentid)
if comment is None or comment.parent.project != project:
flask.abort(404, 'Comment not found')
if (flask.g.fas_user.username != comment.user.username
or comment.parent.status != 'Open') \
and not is_repo_admin(project):
flask.abort(403, 'You are not allowed to edit this comment')
form = pagure.forms.EditCommentForm()
if form.validate_on_submit():
updated_comment = form.update_comment.data
try:
message = pagure.lib.edit_comment(
SESSION,
parent=issue,
comment=comment,
user=flask.g.fas_user.username,
updated_comment=updated_comment,
folder=APP.config['TICKETS_FOLDER'],
)
SESSION.commit()
if not is_js:
flask.flash(message)
except SQLAlchemyError, err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
if is_js:
return 'error'
flask.flash(
'Could not edit the comment: %s' % commentid, 'error')
if is_js:
return 'ok'
return flask.redirect(flask.url_for(
'view_issue', username=username,
repo=project.name, issueid=issueid))
示例2: edit_tag
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def edit_tag(repo, tag, username=None):
""" Edit the specified tag of a project.
"""
repo = pagure.lib.get_project(SESSION, repo, user=username)
if not repo:
flask.abort(404, 'Project not found')
if not is_repo_admin(repo):
flask.abort(
403,
'You are not allowed to edt tags of this project')
form = pagure.forms.AddIssueTagForm()
if form.validate_on_submit():
new_tag = form.tag.data
msgs = pagure.lib.edit_issue_tags(
SESSION, repo, tag, new_tag,
user=flask.g.fas_user.username,
ticketfolder=APP.config['TICKETS_FOLDER']
)
try:
SESSION.commit()
for msg in msgs:
flask.flash(msg)
except SQLAlchemyError, err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
flask.flash('Could not edit tag: %s' % tag, 'error')
return flask.redirect(flask.url_for(
'.view_settings', repo=repo.name, username=username))
示例3: remove_tag
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def remove_tag(repo, username=None):
""" Remove the specified tag from the project.
"""
repo = pagure.lib.get_project(SESSION, repo, user=username)
if not repo:
flask.abort(404, 'Project not found')
if not is_repo_admin(repo):
flask.abort(
403,
'You are not allowed to remove tags of this project')
form = pagure.forms.AddIssueTagForm()
if form.validate_on_submit():
tags = form.tag.data
tags = [tag.strip() for tag in tags.split(',')]
msgs = pagure.lib.remove_tags(
SESSION, repo, tags,
user=flask.g.fas_user.username,
ticketfolder=APP.config['TICKETS_FOLDER']
)
try:
SESSION.commit()
for msg in msgs:
flask.flash(msg)
except SQLAlchemyError, err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
flask.flash(
'Could not remove tag: %s' % ','.join(tags), 'error')
示例4: pull_request_drop_comment
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def pull_request_drop_comment(repo, requestid, username=None):
""" Delete a comment of a pull-request.
"""
repo = pagure.lib.get_project(SESSION, repo, user=username)
if not repo:
flask.abort(404, 'Project not found')
if not repo.settings.get('pull_requests', True):
flask.abort(404, 'No pull-requests found for this project')
request = pagure.lib.search_pull_requests(
SESSION, project_id=repo.id, requestid=requestid)
if not request:
flask.abort(404, 'Pull-request not found')
if flask.request.form.get('edit_comment'):
commentid = flask.request.form.get('edit_comment')
form = pagure.forms.EditCommentForm()
if form.validate_on_submit():
return pull_request_edit_comment(
repo.name, requestid, commentid, username=username)
form = pagure.forms.ConfirmationForm()
if form.validate_on_submit():
if flask.request.form.get('drop_comment'):
commentid = flask.request.form.get('drop_comment')
comment = pagure.lib.get_request_comment(
SESSION, request.uid, commentid)
if comment is None or comment.pull_request.project != repo:
flask.abort(404, 'Comment not found')
if (flask.g.fas_user.username != comment.user.username
or comment.parent.status is False) \
and not is_repo_admin(repo):
flask.abort(
403,
'You are not allowed to remove this comment from '
'this issue')
SESSION.delete(comment)
try:
SESSION.commit()
flask.flash('Comment removed')
except SQLAlchemyError as err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
flask.flash(
'Could not remove the comment: %s' % commentid, 'error')
return flask.redirect(flask.url_for(
'request_pull', username=username,
repo=repo.name, requestid=requestid))
示例5: pull_request_edit_comment
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def pull_request_edit_comment(repo, requestid, commentid, username=None):
"""Edit comment of a pull request
"""
is_js = flask.request.args.get("js", False)
project = pagure.lib.get_project(SESSION, repo, user=username)
if not project:
flask.abort(404, "Project not found")
if not project.settings.get("pull_requests", True):
flask.abort(404, "No pull-requests found for this project")
request = pagure.lib.search_pull_requests(SESSION, project_id=project.id, requestid=requestid)
if not request:
flask.abort(404, "Pull-request not found")
comment = pagure.lib.get_request_comment(SESSION, request.uid, commentid)
if comment is None or comment.parent.project != project:
flask.abort(404, "Comment not found")
if (flask.g.fas_user.username != comment.user.username or comment.parent.status != "Open") and not is_repo_admin(
project
):
flask.abort(403, "You are not allowed to edit the comment")
form = pagure.forms.EditCommentForm()
if form.validate_on_submit():
updated_comment = form.update_comment.data
try:
message = pagure.lib.edit_comment(
SESSION,
parent=request,
comment=comment,
user=flask.g.fas_user.username,
updated_comment=updated_comment,
folder=APP.config["REQUESTS_FOLDER"],
)
SESSION.commit()
if not is_js:
flask.flash(message)
except SQLAlchemyError, err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
if is_js:
return "error"
flask.flash("Could not edit the comment: %s" % commentid, "error")
if is_js:
return "ok"
return flask.redirect(flask.url_for("request_pull", username=username, repo=project.name, requestid=requestid))
示例6: edit_tag
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def edit_tag(repo, tag, username=None):
""" Edit the specified tag associated with the issues of a project.
"""
repo = pagure.lib.get_project(SESSION, repo, user=username)
if not repo:
flask.abort(404, 'Project not found')
if not is_repo_admin(repo):
flask.abort(
403,
'You are not allowed to edit tags associated with the issues of \
this project')
if not repo.settings.get('issue_tracker', True):
flask.abort(404, 'No issue tracker found for this project')
tags = pagure.lib.get_tags_of_project(SESSION, repo)
if not tags or tag not in [t.tag for t in tags]:
flask.abort(404, 'Tag %s not found in this project' % tag )
form = pagure.forms.AddIssueTagForm()
if form.validate_on_submit():
new_tag = form.tag.data
msgs = pagure.lib.edit_issue_tags(
SESSION, repo, tag, new_tag,
user=flask.g.fas_user.username,
ticketfolder=APP.config['TICKETS_FOLDER']
)
try:
SESSION.commit()
for msg in msgs:
flask.flash(msg)
except SQLAlchemyError as err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
flask.flash('Could not edit tag: %s' % tag, 'error')
return flask.redirect(flask.url_for(
'.view_settings', repo=repo.name, username=username))
return flask.render_template(
'edit_tag.html',
form=form,
username=username,
repo=repo,
edit_tag=tag,
)
示例7: remove_tag
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def remove_tag(repo, username=None):
""" Remove the specified tag, associated with the issues, from the project.
"""
repo = pagure.lib.get_project(SESSION, repo, user=username)
if not repo:
flask.abort(404, 'Project not found')
if not is_repo_admin(repo):
flask.abort(
403,
'You are not allowed to remove tags associated with the issues \
of this project')
if not repo.settings.get('issue_tracker', True):
flask.abort(404, 'No issue tracker found for this project')
form = pagure.forms.AddIssueTagForm()
if form.validate_on_submit():
tags = form.tag.data
tags = [tag.strip() for tag in tags.split(',')]
msgs = pagure.lib.remove_tags(
SESSION, repo, tags,
user=flask.g.fas_user.username,
ticketfolder=APP.config['TICKETS_FOLDER']
)
try:
SESSION.commit()
for msg in msgs:
flask.flash(msg)
except SQLAlchemyError as err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
flask.flash(
'Could not remove tag: %s' % ','.join(tags), 'error')
return flask.redirect(
flask.url_for('.view_settings', repo=repo.name, username=username)
)
示例8: update_issue
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def update_issue(repo, issueid, username=None):
''' Add a comment to an issue. '''
is_js = flask.request.args.get('js', False)
repo = pagure.lib.get_project(SESSION, repo, user=username)
if flask.request.method == 'GET':
if not is_js:
flask.flash('Invalid method: GET', 'error')
return flask.redirect(flask.url_for(
'view_issue', username=username, repo=repo.name, issueid=issueid))
if repo is None:
flask.abort(404, 'Project not found')
if not repo.settings.get('issue_tracker', True):
flask.abort(404, 'No issue tracker found for this project')
issue = pagure.lib.search_issues(SESSION, repo, issueid=issueid)
if issue is None or issue.project != repo:
flask.abort(404, 'Issue not found')
if issue.private and not is_repo_admin(repo) \
and (not authenticated() or
not issue.user.user == flask.g.fas_user.username):
flask.abort(
403, 'This issue is private and you are not allowed to view it')
if flask.request.form.get('edit_comment'):
commentid = flask.request.form.get('edit_comment')
form = pagure.forms.EditCommentForm()
if form.validate_on_submit():
return edit_comment_issue(
repo.name, issueid, commentid, username=username)
status = pagure.lib.get_issue_statuses(SESSION)
form = pagure.forms.UpdateIssueForm(
status=status, priorities=repo.priorities)
if form.validate_on_submit():
repo_admin = is_repo_admin(repo)
if flask.request.form.get('drop_comment'):
commentid = flask.request.form.get('drop_comment')
comment = pagure.lib.get_issue_comment(
SESSION, issue.uid, commentid)
if comment is None or comment.issue.project != repo:
flask.abort(404, 'Comment not found')
if (flask.g.fas_user.username != comment.user.username
or comment.parent.status != 'Open') \
and not is_repo_admin(repo):
flask.abort(
403,
'You are not allowed to remove this comment from '
'this issue')
SESSION.delete(comment)
try:
SESSION.commit()
if not is_js:
flask.flash('Comment removed')
except SQLAlchemyError as err: # pragma: no cover
is_js = False
SESSION.rollback()
LOG.error(err)
if not is_js:
flask.flash(
'Could not remove the comment: %s' % commentid,
'error')
if is_js:
return 'ok'
else:
return flask.redirect(flask.url_for(
'view_issue', username=username, repo=repo.name,
issueid=issueid))
comment = form.comment.data
depends = []
for depend in form.depends.data.split(','):
if depend.strip():
try:
depends.append(int(depend.strip()))
except ValueError:
pass
blocks = []
for block in form.blocks.data.split(','):
if block.strip():
try:
blocks.append(int(block.strip()))
except ValueError:
pass
assignee = form.assignee.data
new_status = form.status.data
new_priority = None
try:
#.........這裏部分代碼省略.........
示例9: update_issue
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def update_issue(repo, issueid, username=None, namespace=None):
''' Add a comment to an issue. '''
is_js = flask.request.args.get('js', False)
repo = flask.g.repo
if flask.request.method == 'GET':
if not is_js:
flask.flash('Invalid method: GET', 'error')
return flask.redirect(flask.url_for(
'view_issue', username=username, repo=repo.name,
namespace=repo.namespace, issueid=issueid))
if not repo.settings.get('issue_tracker', True):
flask.abort(404, 'No issue tracker found for this project')
issue = pagure.lib.search_issues(SESSION, repo, issueid=issueid)
if issue is None or issue.project != repo:
flask.abort(404, 'Issue not found')
if issue.private and not flask.g.repo_admin \
and (not authenticated() or
not issue.user.user == flask.g.fas_user.username):
flask.abort(
403, 'This issue is private and you are not allowed to view it')
if flask.request.form.get('edit_comment'):
commentid = flask.request.form.get('edit_comment')
form = pagure.forms.EditCommentForm()
if form.validate_on_submit():
return edit_comment_issue(
repo.name, issueid, commentid, username=username)
status = pagure.lib.get_issue_statuses(SESSION)
form = pagure.forms.UpdateIssueForm(
status=status,
priorities=repo.priorities,
milestones=repo.milestones,
close_status=repo.close_status,
)
if form.validate_on_submit():
repo_admin = flask.g.repo_admin
if flask.request.form.get('drop_comment'):
commentid = flask.request.form.get('drop_comment')
comment = pagure.lib.get_issue_comment(
SESSION, issue.uid, commentid)
if comment is None or comment.issue.project != repo:
flask.abort(404, 'Comment not found')
if (flask.g.fas_user.username != comment.user.username
or comment.parent.status != 'Open') \
and not flask.g.repo_admin:
flask.abort(
403,
'You are not allowed to remove this comment from '
'this issue')
issue.last_updated = datetime.datetime.utcnow()
SESSION.add(issue)
SESSION.delete(comment)
try:
SESSION.commit()
if not is_js:
flask.flash('Comment removed')
except SQLAlchemyError as err: # pragma: no cover
is_js = False
SESSION.rollback()
LOG.error(err)
if not is_js:
flask.flash(
'Could not remove the comment: %s' % commentid,
'error')
if is_js:
return 'ok'
else:
return flask.redirect(flask.url_for(
'view_issue', username=username, repo=repo.name,
namespace=repo.namespace, issueid=issueid))
comment = form.comment.data
depends = []
for depend in form.depends.data.split(','):
if depend.strip():
try:
depends.append(int(depend.strip()))
except ValueError:
pass
blocks = []
for block in form.blocks.data.split(','):
if block.strip():
try:
blocks.append(int(block.strip()))
except ValueError:
pass
#.........這裏部分代碼省略.........
示例10: edit_tag
# 需要導入模塊: from pagure import LOG [as 別名]
# 或者: from pagure.LOG import error [as 別名]
def edit_tag(repo, tag, username=None, namespace=None):
""" Edit the specified tag associated with the issues of a project.
"""
repo = flask.g.repo
if not flask.g.repo_admin:
flask.abort(
403,
'You are not allowed to edit tags associated with the issues of \
this project')
if not repo.settings.get('issue_tracker', True):
flask.abort(404, 'No issue tracker found for this project')
tags = pagure.lib.get_tags_of_project(SESSION, repo)
if not tags:
flask.abort(404, 'Project has no tags to edit')
# Check the tag exists, and get its old/original color
tagobj = pagure.lib.get_tag(SESSION, tag, repo.id)
if not tagobj:
flask.abort(404, 'Tag %s not found in this project' % tag)
form = pagure.forms.AddIssueTagForm()
if form.validate_on_submit():
new_tag = form.tag.data
new_tag_color = form.tag_color.data
msgs = pagure.lib.edit_issue_tags(
SESSION,
repo,
tagobj,
new_tag,
new_tag_color,
user=flask.g.fas_user.username,
ticketfolder=APP.config['TICKETS_FOLDER']
)
try:
SESSION.commit()
for msg in msgs:
flask.flash(msg)
except SQLAlchemyError as err: # pragma: no cover
SESSION.rollback()
LOG.error(err)
flask.flash('Could not edit tag: %s' % tag, 'error')
return flask.redirect(flask.url_for(
'.view_settings', repo=repo.name, username=username,
namespace=repo.namespace))
elif flask.request.method == 'GET':
form.tag_color.data = tagobj.tag_color
form.tag.data = tag
return flask.render_template(
'edit_tag.html',
username=username,
repo=repo,
form=form,
tagname=tag,
)