diff --git a/pagure/__init__.py b/pagure/__init__.py index 1799d0b..66b2230 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -26,7 +26,7 @@ from logging.handlers import SMTPHandler import flask import pygit2 import redis -from flask_fas_openid import FAS +from pagure.flask_fas_openid import FAS from functools import wraps from sqlalchemy.exc import SQLAlchemyError @@ -54,7 +54,7 @@ if 'PAGURE_CONFIG' in os.environ: FAS = FAS(APP) SESSION = pagure.lib.create_session(APP.config['DB_URL']) -REDIS=None +REDIS = None if APP.config['EVENTSOURCE_SOURCE']: POOL = redis.ConnectionPool( host=APP.config['REDIS_HOST'], @@ -69,9 +69,9 @@ if not APP.debug: )) # Send classic logs into syslog -handler = logging.StreamHandler() -handler.setLevel(APP.config.get('log_level', 'INFO')) -APP.logger.addHandler(handler) +SHANDLER = logging.StreamHandler() +SHANDLER.setLevel(APP.config.get('log_level', 'INFO')) +APP.logger.addHandler(SHANDLER) LOG = APP.logger diff --git a/pagure/docs_server.py b/pagure/docs_server.py index 45e55bd..90da7fd 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -37,9 +37,9 @@ if not APP.debug: )) # Send classic logs into syslog -handler = logging.StreamHandler() -handler.setLevel(APP.config.get('log_level', 'INFO')) -APP.logger.addHandler(handler) +SHANDLER = logging.StreamHandler() +SHANDLER.setLevel(APP.config.get('log_level', 'INFO')) +APP.logger.addHandler(SHANDLER) LOG = APP.logger @@ -107,11 +107,13 @@ def markdown_filter(text): # Placeholder to allow re-using pagure's templates @APP.route('/') def index(): + ''' Redirects to the front page of this pagure instance. ''' return flask.redirect(APP.config['APP_URL']) @APP.route('/users/') def view_users(): + ''' Redirects to the list of users on this pagure instance. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -120,6 +122,7 @@ def view_users(): @APP.route('/groups/') def group_lists(): + ''' Redirects to the list of groups on this pagure instance. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -128,6 +131,9 @@ def group_lists(): @APP.route('/new/') def new_project(): + ''' Redirects to the page to create a new project on this pagure + instance. + ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -137,6 +143,7 @@ def new_project(): @APP.route('/repo//') @APP.route('/repo/fork///') def view_repo(repo, username=None): + ''' Redirects to the overview page of this project. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -147,6 +154,7 @@ def view_repo(repo, username=None): @APP.route('//issues/') @APP.route('/fork///issues/') def view_issues(repo, username=None): + ''' Redirects to the page listing all issues of this project. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -159,6 +167,7 @@ def view_issues(repo, username=None): @APP.route('//commits/') @APP.route('/fork///commits/') def view_commits(repo, username=None): + ''' Redirects to the page listing all commits of this project. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -171,6 +180,8 @@ def view_commits(repo, username=None): @APP.route('//tree/') @APP.route('/fork///tree/') def view_tree(repo, username=None): + ''' Redirects to the page displaying the tree of files of this project. + ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -183,6 +194,7 @@ def view_tree(repo, username=None): @APP.route('//tags/') @APP.route('/fork///tags/') def view_tags(repo, username=None): + ''' Redirects to the page listing all tags of this project. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -195,6 +207,7 @@ def view_tags(repo, username=None): @APP.route('//pull-requests/') @APP.route('/fork///pull-requests/') def request_pulls(repo, username=None): + ''' Redirects to the page listing all pull-requests of this project. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] @@ -207,6 +220,7 @@ def request_pulls(repo, username=None): @APP.route('//forks/') @APP.route('/fork///forks/') def view_forks(repo, username=None): + ''' Redirects to the page listing all forks of this project. ''' root_url = APP.config['APP_URL'] if root_url.endswith('/'): root_url = root_url[:-1] diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index f2c2b8a..91615aa 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -269,7 +269,7 @@ def add_tag_obj(session, obj, tags, user, ticketfolder, redis=None): def add_issue_assignee(session, issue, assignee, user, ticketfolder, - redis=None): + redis=None): ''' Add an assignee to an issue, in other words, assigned an issue. ''' user_obj = __get_user(session, user) @@ -812,7 +812,7 @@ def add_pull_request_flag(session, request, username, percent, comment, url, def new_project(session, user, name, blacklist, gitfolder, docfolder, ticketfolder, requestfolder, - description=None, url=None,avatar_email=None, + description=None, url=None, avatar_email=None, parent_id=None): ''' Create a new project based on the information provided. ''' @@ -1785,7 +1785,8 @@ def update_user_ssh(session, user, ssh_key): message = 'Nothing to update' - ssh_key = ssh_key.strip().replace('\n', '') if ssh_key and ssh_key.strip() else None + ssh_key = ssh_key.strip().replace('\n', '') \ + if ssh_key and ssh_key.strip() else None if ssh_key != user.public_ssh_key: user.public_ssh_key = ssh_key diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 8ba63af..a9f3a5b 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -150,8 +150,9 @@ def update_git(obj, repo, repofolder, objtype='ticket'): # Write down what changed with open(file_path, 'w') as stream: - stream.write(json.dumps(obj.to_json(), - sort_keys=True, indent=4, separators=(',', ': '))) + stream.write(json.dumps( + obj.to_json(), sort_keys=True, indent=4, + separators=(',', ': '))) # Retrieve the list of files that changed diff = new_repo.diff() @@ -231,8 +232,6 @@ def clean_git(obj, repo, repofolder, objtype='ticket'): # Remove the file os.unlink(file_path) - diff = new_repo.diff() - # Add the changes to the index index.remove(obj.uid) @@ -756,15 +755,15 @@ def read_output(cmd, abspath, input=None, keepends=False, **kw): stdin = subprocess.PIPE else: stdin = None - p = subprocess.Popen( + procs = subprocess.Popen( cmd, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=abspath, **kw) - (out, err) = p.communicate(input) - retcode = p.wait() + (out, err) = procs.communicate(input) + retcode = procs.wait() if retcode: print 'ERROR: %s =-- %s' % (cmd, retcode) print out diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 64887a1..9a2e53d 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -373,8 +373,8 @@ class Project(BASE): 'id': self.id, 'name': self.name, 'description': self.description, - 'parent': self.parent.to_json(public=public, api=api) - if self.parent else None, + 'parent': self.parent.to_json( + public=public, api=api) if self.parent else None, 'date_created': self.date_created.strftime('%s'), 'user': self.user.to_json(public=public), } @@ -509,8 +509,8 @@ class Issue(BASE): 'tags': self.tags_text, 'depends': [str(item) for item in self.depends_text], 'blocks': [str(item) for item in self.blocks_text], - 'assignee': self.assignee.to_json(public=public) - if self.assignee else None, + 'assignee': self.assignee.to_json( + public=public) if self.assignee else None, } comments = [] @@ -601,12 +601,12 @@ class IssueComment(BASE): ''' output = { - 'id': self.id, - 'comment': self.comment, - 'parent': self.parent_id, - 'date_created': self.date_created.strftime('%s'), - 'user': self.user.to_json(public=public), - } + 'id': self.id, + 'comment': self.comment, + 'parent': self.parent_id, + 'date_created': self.date_created.strftime('%s'), + 'user': self.user.to_json(public=public), + } return output @@ -826,13 +826,13 @@ class PullRequest(BASE): 'repo_from': self.project_from.to_json(public=public, api=api), 'date_created': self.date_created.strftime('%s'), 'user': self.user.to_json(public=public), - 'assignee': self.assignee.to_json(public=public) - if self.assignee else None, + 'assignee': self.assignee.to_json( + public=public) if self.assignee else None, 'status': self.status, 'commit_start': self.commit_start, 'commit_stop': self.commit_stop, - 'closed_by': self.closed_by.to_json(public=public) - if self.closed_by else None, + 'closed_by': self.closed_by.to_json( + public=public) if self.closed_by else None, } comments = [] diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 7eb2491..7775763 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -224,10 +224,10 @@ def request_pull_patch(repo, requestid, username=None): break else: try: - diff_commits, diff = pagure.lib.git.diff_pull_request( + diff_commits = pagure.lib.git.diff_pull_request( SESSION, request, repo_obj, orig_repo, requestfolder=APP.config['REQUESTS_FOLDER'], - with_diff=False) + with_diff=False)[0] except pagure.exceptions.PagureException as err: flask.flash(err.message, 'error') return flask.redirect(flask.url_for( @@ -697,7 +697,7 @@ def new_request_pull(repo, branch_to, branch_from, username=None): return flask.redirect(flask.url_for( 'view_repo', username=username, repo=repo.name)) - repo_admin=is_repo_admin(repo) + repo_admin = is_repo_admin(repo) form = pagure.forms.RequestPullForm() if form.validate_on_submit() and repo_admin: diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index ca6021f..909b524 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -21,7 +21,7 @@ import mimetypes import pagure.doc_utils import pagure.lib import pagure.forms -from pagure import (APP, SESSION, REDIS, LOG, __get_file_in_tree, +from pagure import (APP, SESSION, REDIS, LOG, __get_file_in_tree, cla_required, is_repo_admin, authenticated)