From 6492f117865f8d443d8a1f6b343769d543bba9f2 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mar 24 2017 08:34:53 +0000 Subject: Minor flake8 fixes Fix adds minor flake8 related changes in alembic and pagure_stream_server Signed-off-by: Abhijeet Kasurde --- diff --git a/alembic/env.py b/alembic/env.py index fa22c7f..d177918 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -88,4 +88,3 @@ if context.is_offline_mode(): run_migrations_offline() else: run_migrations_online() - diff --git a/ev-server/pagure_stream_server.py b/ev-server/pagure_stream_server.py index 64360e9..b6b1eac 100644 --- a/ev-server/pagure_stream_server.py +++ b/ev-server/pagure_stream_server.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ - (c) 2015 - Copyright Red Hat Inc + (c) 2015-2017 - Copyright Red Hat Inc Authors: Pierre-Yves Chibon @@ -19,7 +19,6 @@ nc localhost 8080 """ -import datetime import logging import os import urlparse @@ -110,7 +109,8 @@ def _parse_path(path): try: objtype = [item for item in items if item in OBJECTS][-1] except IndexError: - raise PagureEvException("No known object type found in path: %s" % path) + raise PagureEvException( + "No known object type found in path: %s" % path) try: # objid is the item after objtype, we need all items up to it items = items[:items.index(objtype) + 2] @@ -118,7 +118,8 @@ def _parse_path(path): (repo, objtype, objid) = items[-3:] items = items[:-3] except (IndexError, ValueError): - raise PagureEvException("No project or object ID found in path: %s" % path) + raise PagureEvException( + "No project or object ID found in path: %s" % path) # now check for a fork if items and items[0] == 'fork': try: @@ -126,22 +127,27 @@ def _parse_path(path): username = items[1] items = items[2:] except IndexError: - raise PagureEvException("Path starts with /fork but no user found! Path: %s" % path) + raise PagureEvException( + "Path starts with /fork but no user found! Path: %s" % path) # if we still have an item left, it must be the namespace if items: namespace = items.pop(0) # if we have any items left at this point, we've no idea if items: - raise PagureEvException("More path components than expected! Path: %s" % path) + raise PagureEvException( + "More path components than expected! Path: %s" % path) - return (username, namespace, repo, objtype, objid) + return username, namespace, repo, objtype, objid def get_obj_from_path(path): """ Return the Ticket or Request object based on the path provided. """ (username, namespace, reponame, objtype, objid) = _parse_path(path) - repo = pagure.lib.get_project(pagure.SESSION, reponame, user=username, namespace=namespace) + repo = pagure.lib.get_project(pagure.SESSION, + reponame, + user=username, + namespace=namespace) if repo is None: raise PagureEvException("Project '%s' not found" % reponame) @@ -178,7 +184,7 @@ def handle_client(client_reader, client_writer): log.warning("No URL provided: %s" % data) return - if not '/' in data[1]: + if '/' not in data[1]: log.warning("Invalid URL provided: %s" % data[1]) return @@ -218,7 +224,6 @@ def handle_client(client_reader, client_writer): # Inside a while loop, wait for incoming events. while True: reply = yield trollius.From(subscriber.next_published()) - #print(u'Received: ', repr(reply.value), u'on channel', reply.channel) log.info(reply) log.info("Sending %s", reply.value) client_writer.write(('data: %s\n\n' % reply.value).encode()) @@ -248,7 +253,6 @@ def stats(client_reader, client_writer): except trollius.ConnectionResetError as err: log.info(err) - pass finally: client_writer.close() return @@ -265,7 +269,8 @@ def main(): port=pagure.APP.config['EVENTSOURCE_PORT'], loop=loop) SERVER = loop.run_until_complete(coro) - log.info('Serving server at {}'.format(SERVER.sockets[0].getsockname())) + log.info( + 'Serving server at {}'.format(SERVER.sockets[0].getsockname())) if pagure.APP.config.get('EV_STATS_PORT'): stats_coro = trollius.start_server( stats,