Commit 48dfdf4 Fix all flake8 errors

39 files Authored and Committed by abompard 3 months ago
Fix all flake8 errors

    
1 @@ -16,7 +16,6 @@
2   from __future__ import unicode_literals, print_function
3   
4   import sys
5 - import dogpile.cache
6   
7   import hubs.app
8   import hubs.widgets
 1 @@ -13,14 +13,14 @@
 2   Authors:    Ralph Bean <rbean@redhat.com>
 3   """
 4   
 5 - from __future__ import unicode_literals
 6 + from __future__ import unicode_literals, print_function
 7 + 
 8 + import retask
 9   
10   import fedmsg.config
11   config = fedmsg.config.load_config()
12   
13 - import retask
14 - 
15   for item in ['triage', 'work']:
16       queue = retask.queue.Queue(config['hubs.redis.%s-queue-name' % item])
17       queue.connect()
18 -     print ' (%s) queue length is %i' % (item, queue.length)
19 +     print(' (%s) queue length is %i' % (item, queue.length))
 1 @@ -4,32 +4,31 @@
 2   Useful for testing what happens when you recreate them.
 3   """
 4   
 5 - from __future__ import unicode_literals
 6 - 
 7 - import sys
 8 + from __future__ import unicode_literals, print_function
 9   
10   import fedmsg.config
11 - fedmsg_config = fedmsg.config.load_config()
12   
13   import hubs.models
14   
15 + fedmsg_config = fedmsg.config.load_config()
16 + 
17   session = hubs.models.init(fedmsg_config['hubs.sqlalchemy.uri'])
18   
19 - username = raw_input('What user do you want to delete: ')
20 + username = input('What user do you want to delete: ')
21   openid = '%s.id.fedoraproject.org' % username
22 - print "Looking for account %r" % openid
23 + print("Looking for account %r" % openid)
24   user = hubs.models.User.get(openid)
25   if not user:
26 -     print "No such user %r" % openid
27 +     print("No such user %r" % openid)
28   else:
29 -     print "Found %r.  Deleting." % user
30 +     print("Found %r.  Deleting." % user)
31       session.delete(user)
32   
33   hub = hubs.models.Hub.get(username)
34   if not hub:
35 -     print "No such hub %r" % username
36 +     print("No such hub %r" % username)
37   else:
38 -     print "Found %r.  Deleting." % hub
39 +     print("Found %r.  Deleting." % hub)
40       session.delete(hub)
41   
42   session.commit()
 1 @@ -150,8 +150,8 @@
 2   # html_logo = None
 3   
 4   # The name of an image file (relative to this directory) to use as a favicon of
 5 - # the docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
 6 - # pixels large.
 7 + # the docs.  This file should be a Windows icon file (.ico) being 16x16 or
 8 + # 32x32 pixels large.
 9   #
10   # html_favicon = None
11   
 1 @@ -17,8 +17,6 @@
 2   #
 3   # Authors:  Ralph Bean <rbean@redhat.com>
 4   
 5 - import os
 6 - 
 7   config = dict(
 8       # Set this to dev if you're hacking on fedmsg or an app.
 9       # Set to stg or prod if running in the Fedora Infrastructure
10 @@ -28,14 +26,14 @@
11       high_water_mark=0,
12       io_threads=1,
13   
14 -     ## For the fedmsg-hub and fedmsg-relay. ##
15 +     # # For the fedmsg-hub and fedmsg-relay. # #
16   
17       # This is a status dir to keep a record of the last processed message
18 -     #status_directory=os.getcwd() + "/status",
19 -     #status_directory='/var/run/fedmsg/status',
20 +     # status_directory=os.getcwd() + "/status",
21 +     # status_directory='/var/run/fedmsg/status',
22   
23       # This is the URL of a datagrepper instance that we can query for backlog.
24 -     #datagrepper_url="https://apps.fedoraproject.org/datagrepper/raw",
25 +     # datagrepper_url="https://apps.fedoraproject.org/datagrepper/raw",
26   
27       # We almost always want the fedmsg-hub to be sending messages with zmq as
28       # opposed to amqp or stomp.
 1 @@ -21,7 +21,8 @@
 2           ]
 3       },
 4   
 5 -     'datanommer.sqlalchemy.uri': 'postgres://postgres:laksjdf@127.0.0.1/datanommer',
 6 +     'datanommer.sqlalchemy.uri':
 7 +         'postgres://postgres:laksjdf@127.0.0.1/datanommer',
 8   
 9       'fmn.url': 'https://apps.fedoraproject.org/notifications',
10   
11 @@ -47,7 +48,8 @@
12   
13       # Run datanommer locally, just for development.
14       'datanommer.enabled': True,
15 -     'datanommer.sqlalchemy.url': 'postgres://postgres:laksjdf@127.0.0.1/datanommer',
16 +     'datanommer.sqlalchemy.url':
17 +         'postgres://postgres:laksjdf@127.0.0.1/datanommer',
18   
19       # Only do one of these so we can try to not run out of memory.
20       'moksha.workers_per_consumer': 1,
 1 @@ -1,20 +1,18 @@
 2   from __future__ import unicode_literals
 3   
 4   import datetime
 5 - import json
 6   import logging
 7   import os
 8   
 9 + import datanommer.models
10 + import fedmsg.config
11 + import fedmsg.meta
12   import flask
13   import flask.json
14   import munch
15 - 
16   from flask_oidc import OpenIDConnect
17   
18   import hubs.models
19 - 
20 - import datanommer.models
21 - 
22   from hubs.utils import username2avatar
23   
24   app = flask.Flask(__name__)
25 @@ -34,15 +32,13 @@
26   if 'HUBS_CONFIG' in os.environ:
27       app.config.from_envvar('HUBS_CONFIG')
28   
29 - import fedmsg.config
30 - import fedmsg.meta
31 - 
32   fedmsg_config = fedmsg.config.load_config()
33   fedmsg.meta.make_processors(**fedmsg_config)
34   
35   session = hubs.models.init(fedmsg_config['hubs.sqlalchemy.uri'])
36   datanommer.models.init(fedmsg_config['datanommer.sqlalchemy.uri'])
37   
38 + 
39   @app.before_request
40   def store_db():
41       flask.g.db = session
42 @@ -74,7 +70,7 @@
43   
44   
45   # Set up OpenIDConnect
46 - OIDC = OpenIDConnect(app, credentials_store=flask.session )
47 + OIDC = OpenIDConnect(app, credentials_store=flask.session)
48   
49   
50   @app.before_request
51 @@ -86,17 +82,16 @@
52           if not hasattr(flask.session, 'auth') or not flask.session.auth:
53               flask.session.auth = munch.Munch(
54                   fullname=OIDC.user_getfield('name'),
55 -                 nickname=OIDC.user_getfield('nickname') \
56 -                     or OIDC.user_getfield('sub'),
57 +                 nickname=(OIDC.user_getfield('nickname') or
58 +                           OIDC.user_getfield('sub')),
59                   email=OIDC.user_getfield('email'),
60                   timezone=OIDC.user_getfield('zoneinfo'),
61 -                 cla_done=\
62 -                     'http://admin.fedoraproject.org/accounts/cla/done' \
63 -                     in OIDC.user_getfield('cla'),
64 +                 cla_done=('http://admin.fedoraproject.org/accounts/cla/done'
65 +                           in OIDC.user_getfield('cla')),
66                   groups=OIDC.user_getfield('groups'),
67                   logged_in=True,
68               )
69 -             flask.session.auth.avatar=username2avatar(
70 +             flask.session.auth.avatar = username2avatar(
71                   flask.session.auth.nickname)
72               flask.session.auth.user = hubs.models.User.by_username(
73                   flask.session.auth.nickname)
74 @@ -105,11 +100,11 @@
75           flask.g.auth = munch.Munch(logged_in=False)
76   
77   # Register widgets
78 - import hubs.widgets
79 + import hubs.widgets  # noqa
80   hubs.widgets.registry.register_list(app.config["WIDGETS"])
81   
82   # Register routes
83 - import hubs.views
84 + import hubs.views  # noqa
85   
86   # Add widget-specific routes
87   hubs.widgets.registry.register_routes(app)
 1 @@ -21,28 +21,27 @@
 2   
 3   from __future__ import unicode_literals
 4   
 5 - import hubs.app
 6 - import hubs.models
 7 - 
 8 - import hubs.widgets.base
 9 + import json
10 + import logging
11 + import logging.config
12 + import random
13 + import sys
14   
15   import fedmsg.config
16   import fedmsg.meta
17 - config = fedmsg.config.load_config()
18 - 
19   import retask.queue
20   
21 - import json
22 - import random
23 - import sys
24 - import logging
25 - import logging.config
26 + import hubs.app
27 + import hubs.models
28 + import hubs.widgets.base
29 + 
30 + 
31   log = logging.getLogger('hubs.backend.triage')
32 + config = fedmsg.config.load_config()
33   
34   
35   def triage(session, outbound, msg):
36       topic = msg['topic']
37 -     category = topic.split('.')[3]
38   
39       for suffix in config['hubs.junk_suffixes']:
40           if topic.endswith(suffix):
41 @@ -115,5 +114,6 @@
42   
43       return 0
44   
45 + 
46   if __name__ == '__main__':
47       sys.exit(main(sys.argv))
 1 @@ -26,29 +26,29 @@
 2   
 3   from __future__ import unicode_literals
 4   
 5 - import hubs.app
 6 - import hubs.models
 7 - 
 8 - import hubs.widgets.base
 9 + import json
10 + import logging
11 + import logging.config
12 + import sys
13   
14   import fedmsg.config
15   import fedmsg.meta
16 - config = fedmsg.config.load_config()
17 - 
18   import retask.queue
19   
20 - import json
21 - import sys
22 - import logging
23 - import logging.config
24 + import hubs.app
25 + import hubs.models
26 + import hubs.widgets.base
27 + 
28 + 
29   log = logging.getLogger('hubs.backend.worker')
30 + config = fedmsg.config.load_config()
31   
32   
33   def work(widget_idx, fn_name):
34       # Get a real widget, because we update last_refreshed on it.
35       widget = hubs.models.Widget.by_idx(widget_idx)
36       fn_class = widget.module.get_cached_functions()[fn_name]
37 -     log.info("! Rebuilding cache for %r:%r" % (widget, cached_fn))
38 +     log.info("! Rebuilding cache for %r:%r" % (widget, fn_name))
39       # Invalidate the cache...
40       fn_class(widget).rebuild()
41       # TODO -- fire off an EventSource notice that we updated stuff
42 @@ -88,7 +88,6 @@
43               task = queue.wait()  # Wait forever...  timeout is optional.
44               log.info("Working on %r.  (backlog is %r)" % (task, queue.length))
45               item = json.loads(task.data)
46 -             idx = item['idx']  # A widget ID
47               handle(item['idx'], item['fn_name'])
48               log.debug("  Done.")
49       except KeyboardInterrupt:
50 @@ -96,5 +95,6 @@
51   
52       return 0
53   
54 + 
55   if __name__ == '__main__':
56       sys.exit(main(sys.argv))
 1 @@ -31,7 +31,8 @@
 2   
 3   # TODO - instead of 'develop', use the version from pkg_resources to figure out
 4   #        the right tag to link people to.  AGPL ftw.
 5 - SOURCE_URL = 'https://pagure.io/fedora-hubs/blob/develop/f'  # /hubs/widgets/badges.py'
 6 + SOURCE_URL = 'https://pagure.io/fedora-hubs/blob/develop/f'
 7 + # Example of what will be appended: '/hubs/widgets/badges.py'
 8   
 9   CHAT_NETWORKS = [
10       {
 1 @@ -20,9 +20,9 @@
 2       # Right Side Widgets
 3       widget = hubs.models.Widget(
 4           plugin='contact', index=-2,
 5 -             _config=json.dumps({
 6 -                 'username': username,
 7 -             }))
 8 +         _config=json.dumps({
 9 +             'username': username,
10 +         }))
11       hub.widgets.append(widget)
12   
13       widget = hubs.models.Widget(
 1 @@ -1,25 +1,24 @@
 2   from __future__ import absolute_import, unicode_literals
 3   
 4 - from alembic import context
 5 - from sqlalchemy import create_engine, pool
 6   from logging.config import fileConfig
 7   
 8 - 
 9   import fedmsg.config
10 - 
11 - fedmsg_config = fedmsg.config.load_config()
12 + from alembic import context
13 + from sqlalchemy import create_engine, pool
14   
15   
16   try:
17 -     import hubs
18 +     import hubs  # noqa
19   except ImportError:
20 -     import os, sys
21 +     import os
22 +     import sys
23       if "hubs" not in os.listdir("."):
24           raise
25       sys.path.append(os.getcwd())
26   
27   from hubs.models import BASE
28   
29 + 
30   # This is the Alembic Config object, which provides
31   # access to the values within the .ini file in use.
32   # The config_file_name property may be None when used programatically.
33 @@ -28,6 +27,7 @@
34       # This line sets up loggers basically.
35       fileConfig(context.config.config_file_name)
36   
37 + fedmsg_config = fedmsg.config.load_config()
38   url = fedmsg_config['hubs.sqlalchemy.uri']
39   target_metadata = BASE.metadata
40   
41 @@ -73,6 +73,7 @@
42           with context.begin_transaction():
43               context.run_migrations()
44   
45 + 
46   if context.is_offline_mode():
47       run_migrations_offline()
48   else:
 1 @@ -35,11 +35,13 @@
 2   
 3   
 4   def upgrade():
 5 -     op.create_table('hubs_config',
 6 +     op.create_table(
 7 +         'hubs_config',
 8           sa.Column('id', sa.Integer(), nullable=False),
 9           sa.Column('hub_id', sa.String(length=50), nullable=False),
10           sa.Column('summary', sa.String(length=128), nullable=True),
11 -         sa.Column('left_width', sa.Integer(), nullable=False, server_default="8"),
12 +         sa.Column('left_width', sa.Integer(), nullable=False,
13 +                   server_default="8"),
14           sa.Column('avatar', sa.String(length=256), nullable=True),
15           sa.Column('header_img', sa.String(length=256), nullable=True),
16           sa.ForeignKeyConstraint(['hub_id'], ['hubs.name'], ),
17 @@ -59,13 +61,20 @@
18   
19   
20   def downgrade():
21 -     op.add_column('hubs', sa.Column('avatar', sa.VARCHAR(length=256), nullable=True))
22 -     op.add_column('hubs', sa.Column('summary', sa.VARCHAR(length=128), nullable=True))
23 -     op.add_column('hubs', sa.Column('header_img', sa.VARCHAR(length=256), nullable=True))
24 -     op.add_column('hubs', sa.Column('left_width', sa.INTEGER(), server_default="8", nullable=False))
25 +     op.add_column(
26 +         'hubs', sa.Column('avatar', sa.VARCHAR(length=256), nullable=True))
27 +     op.add_column(
28 +         'hubs', sa.Column('summary', sa.VARCHAR(length=128), nullable=True))
29 +     op.add_column(
30 +         'hubs', sa.Column('header_img', sa.VARCHAR(length=256), nullable=True))
31 +     op.add_column(
32 +         'hubs', sa.Column('left_width', sa.INTEGER(), server_default="8",
33 +                           nullable=False))
34       connection = op.get_bind()
35 -     query = "SELECT hub_id, summary, left_width, avatar, header_img FROM hubs_config"
36 -     hubs_table = sa.sql.table('hubs',
37 +     query = ("SELECT hub_id, summary, left_width, avatar, header_img "
38 +              "FROM hubs_config")
39 +     hubs_table = sa.sql.table(
40 +         'hubs',
41           sa.sql.column('name', sa.String),
42           sa.sql.column('summary', sa.String),
43           sa.sql.column('left_width', sa.Integer),
44 @@ -74,7 +83,7 @@
45       )
46       for row in connection.execute(query):
47           op.execute(hubs_table.update().where(
48 -             hubs_table.c.name==op.inline_literal(row["hub_id"])
49 +             hubs_table.c.name == op.inline_literal(row["hub_id"])
50               ).values({
51                   "summary": op.inline_literal(row["summary"]),
52                   "left_width": op.inline_literal(row["left_width"]),
  1 @@ -30,7 +30,6 @@
  2   import random
  3   
  4   import bleach
  5 - import dogpile
  6   import sqlalchemy as sa
  7   
  8   from alembic import command as alembic_command
  9 @@ -69,7 +68,7 @@
 10   log = logging.getLogger(__name__)
 11   
 12   
 13 - placekitten = lambda: "https://placekitten.com/g/320/320"
 14 + placekitten = "https://placekitten.com/g/320/320"
 15   
 16   
 17   def randomheader():
 18 @@ -122,8 +121,10 @@
 19                           primary_key=True)
 20       role = sa.Column(sa.Enum(*roles), primary_key=True)
 21   
 22 -     user = relation("User", backref=backref('associations', cascade="all, delete"))
 23 -     hub = relation("Hub", backref=backref('associations', cascade="all, delete"))
 24 +     user = relation("User", backref=backref(
 25 +         'associations', cascade="all, delete"))
 26 +     hub = relation("Hub", backref=backref(
 27 +         'associations', cascade="all, delete"))
 28   
 29       @classmethod
 30       def get(cls, hub, user, role):
 31 @@ -139,7 +140,8 @@
 32       name = sa.Column(sa.String(50), primary_key=True)
 33       created_on = sa.Column(sa.DateTime, default=datetime.datetime.utcnow)
 34       widgets = relation('Widget', cascade='all,delete', backref='hub')
 35 -     config = relation('HubConfig', uselist=False, cascade='all,delete', backref='hub')
 36 +     config = relation('HubConfig', uselist=False, cascade='all,delete',
 37 +                       backref='hub')
 38       archived = sa.Column(sa.Boolean, default=False)
 39       user_hub = sa.Column(sa.Boolean, default=False)
 40       # Timestamps about various kinds of "freshness"
 41 @@ -358,7 +360,6 @@
 42           self._config = json.dumps(config)
 43   
 44       def __json__(self):
 45 -         session = object_session(self)
 46           module = hubs.widgets.registry[self.plugin]
 47           root_view = module.get_views()["root"](module)
 48           data = root_view.get_context(self)
 49 @@ -395,7 +396,7 @@
 50       fullname = sa.Column(sa.Text)
 51       created_on = sa.Column(sa.DateTime, default=datetime.datetime.utcnow)
 52       saved_notifications = relation('SavedNotification', backref='users',
 53 -                                        lazy='dynamic')
 54 +                                    lazy='dynamic')
 55   
 56       def __json__(self):
 57           return {
 58 @@ -432,10 +433,10 @@
 59           # TODO -- someday make this editable/configurable.
 60           return sorted(list(set([
 61               assoc.hub for assoc in self.associations
 62 -             if assoc.role == 'member'
 63 -             or assoc.role == 'subscriber'
 64 -             or assoc.role == 'owner'
 65 -             and assoc.hub.name != self.username
 66 +             if assoc.role == 'member' or
 67 +             assoc.role == 'subscriber' or
 68 +             assoc.role == 'owner' and
 69 +             assoc.hub.name != self.username
 70           ])), key=operator.attrgetter('name'))
 71   
 72       @classmethod
 73 @@ -468,16 +469,16 @@
 74       __tablename__ = 'visit_counter'
 75       count = sa.Column(sa.Integer, default=0, nullable=False)
 76   
 77 -     visited_hub = sa.Column(sa.String(50),
 78 -                        sa.ForeignKey('hubs.name'),
 79 -                        primary_key=True)
 80 +     visited_hub = sa.Column(sa.String(50), sa.ForeignKey('hubs.name'),
 81 +                             primary_key=True)
 82   
 83 -     username = sa.Column(sa.Text,
 84 -                         sa.ForeignKey('users.username'),
 85 -                         primary_key=True)
 86 +     username = sa.Column(sa.Text, sa.ForeignKey('users.username'),
 87 +                          primary_key=True)
 88   
 89 -     user = relation("User", backref=backref('visit_counters', cascade="all, delete, delete-orphan"))
 90 -     hub = relation("Hub", backref=backref('visit_counters', cascade="all, delete, delete-orphan"))
 91 +     user = relation("User", backref=backref(
 92 +                     'visit_counters', cascade="all, delete, delete-orphan"))
 93 +     hub = relation("Hub", backref=backref(
 94 +                    'visit_counters', cascade="all, delete, delete-orphan"))
 95   
 96       @classmethod
 97       def by_username(cls, username):
 98 @@ -485,7 +486,8 @@
 99   
100       @classmethod
101       def get_visits_by_username_hub(cls, username, visited_hub):
102 -         return cls.query.filter_by(username=username, visited_hub=visited_hub).first()
103 +         return cls.query.filter_by(
104 +             username=username, visited_hub=visited_hub).first()
105   
106       @classmethod
107       def increment_visits(cls, session, username, visited_hub):
108 @@ -534,8 +536,8 @@
109       markup = sa.Column(sa.Text)
110       secondary_icon = sa.Column(sa.Text)
111   
112 - 
113 -     def __init__(self, username=None, markup='', link='', secondary_icon='', dom_id=''):
114 +     def __init__(self, username=None, markup='', link='', secondary_icon='',
115 +                  dom_id=''):
116           self.user = username
117           self.markup = markup
118           self.link = link
 1 @@ -1,8 +1,8 @@
 2   from __future__ import unicode_literals
 3   
 4 - import json
 5   import os
 6   
 7 + 
 8   class Stream(object):
 9       def get_json(self):
10           here = os.path.dirname(os.path.abspath(__file__))
1 @@ -1,7 +1,5 @@
2   from __future__ import unicode_literals
3   
4 - import flask
5 - import unittest
6   from six.moves.urllib.parse import urlparse
7   
8   import hubs.tests
1 @@ -1,7 +1,6 @@
2   from __future__ import unicode_literals
3   
4   import json
5 - from six.moves.urllib.parse import urlparse
6   
7   import hubs.tests
8   import hubs.models
 1 @@ -404,7 +404,8 @@
 2                   "left_width": 8,
 3                   "avatar": (
 4                       "https://seccdn.libravatar.org/avatar/9c9f7784935381befc30"
 5 -                     "2fe3c814f9136e7a33953d0318761669b8643f4df55c?s=312&d=retro"
 6 +                     "2fe3c814f9136e7a33953d0318761669b8643f4df55c"
 7 +                     "?s=312&d=retro"
 8                       ),
 9                   "chat_channel": None,
10                   "chat_domain": None,
 1 @@ -8,15 +8,16 @@
 2   
 3   from mock import Mock
 4   from hubs.tests import APPTest
 5 - #import hubs.models
 6   
 7   
 8   class TestingWidget(Widget):
 9       name = "testing"
10   
11 + 
12   class TestingView(WidgetView):
13       name = "root"
14   
15 + 
16   class TestingFunction(CachedFunction):
17       pass
18   
19 @@ -40,8 +41,10 @@
20       def test_validate(self):
21           class LocalTestWidget(Widget):
22               views = {}
23 + 
24               def get_views(self):
25                   return self.views
26 + 
27           self.assertRaisesRegexp(
28               AttributeError, '.* "name" .*', LocalTestWidget)
29           LocalTestWidget.name = "invalid name \xe2\x98\xba"
30 @@ -109,10 +112,11 @@
31               {"TestingFunction": TestingFunction}
32               )
33   
34 -     def test_list_views(self):
35 +     def test_list_additional_views(self):
36           class TestView1(WidgetView):
37               name = "root"
38               url_rules = ["/", "/test-1/"]
39 + 
40           class TestView2(WidgetView):
41               name = "test2"
42               url_rules = ["/test-2"]
43 @@ -127,7 +131,9 @@
44           self.assertIn("testing_root",
45                         self.app.application.url_map._rules_by_endpoint)
46           self.assertIn("testing_root", self.app.application.view_functions)
47 -         rules = list(self.app.application.url_map.iter_rules(endpoint="testing_root"))
48 +         rules = list(
49 +             self.app.application.url_map.iter_rules(endpoint="testing_root")
50 +             )
51           self.assertEqual(len(rules), 2)
52           self.assertEqual(rules[0].rule, "/<hub>/w/testing/<int:idx>/")
53           self.assertEqual(rules[1].rule, "/<hub>/w/testing/<int:idx>/test-1/")
54 @@ -135,6 +141,8 @@
55           self.assertIn("testing_test2",
56                         self.app.application.url_map._rules_by_endpoint)
57           self.assertIn("testing_test2", self.app.application.view_functions)
58 -         rules = list(self.app.application.url_map.iter_rules(endpoint="testing_test2"))
59 +         rules = list(
60 +             self.app.application.url_map.iter_rules(endpoint="testing_test2")
61 +             )
62           self.assertEqual(len(rules), 1)
63           self.assertEqual(rules[0].rule, "/<hub>/w/testing/<int:idx>/test-2")
 1 @@ -1,13 +1,10 @@
 2   from __future__ import unicode_literals
 3   
 4 - import six
 5   import unittest
 6   
 7   from hubs.widgets import validators
 8   
 9 - #from mock import Mock
10   from hubs.tests import APPTest
11 - from hubs.models import User
12   
13   
14   class ValidatorsTest(APPTest):
15 @@ -30,7 +27,8 @@
16   
17       def test_username(self):
18           self.assertEqual(validators.Username.from_string("ralph"), "ralph")
19 -         self.assertRaises(ValueError, validators.Username.from_string, "nobody")
20 +         self.assertRaises(
21 +             ValueError, validators.Username.from_string, "nobody")
22   
23       @unittest.skip("Not implemented yet")
24       def test_github_organization(self):
 1 @@ -1,12 +1,6 @@
 2   from __future__ import unicode_literals
 3   
 4   import json
 5 - from datetime import datetime, timedelta
 6 - from os.path import dirname
 7 - import unittest
 8 - 
 9 - import requests
10 - import vcr
11   
12   import hubs.models
13   from hubs.tests import APPTest
14 @@ -20,7 +14,8 @@
15           widget = hubs.models.Widget(
16               plugin='library',
17               index=51,
18 -             _config=json.dumps({"urls": "ralph/"})  # we must add a url or itll crash
19 +             # We must add a url in the config or it'll crash.
20 +             _config=json.dumps({"urls": "ralph/"})
21           )
22           hub.widgets.append(widget)
23           hubs.app.session.commit()
1 @@ -2,8 +2,6 @@
2   
3   import json
4   
5 - from nose.tools import assert_dict_equal
6 - 
7   import hubs.tests.test_widgets
8   
9   
 1 @@ -2,7 +2,6 @@
 2   
 3   import json
 4   
 5 - from mock import patch, MagicMock
 6   import hubs.tests.test_widgets
 7   
 8   
 9 @@ -29,7 +28,8 @@
10       def test_should_invalidate_wrong_user(self):
11           widget = self.widget_instance('ralph', self.plugin)
12           # msg = self.get_fedmsg('2016-e371c7f6-bc8e-4632-8e33-b9102dc30b5f')
13 -         msg = {'topic': 'fedbadges.badge.award', 'msg': {'user': {'username': 'not_ralph'}}}
14 +         msg = {'topic': 'fedbadges.badge.award',
15 +                'msg': {'user': {'username': 'not_ralph'}}}
16           module = hubs.widgets.registry[widget.plugin]
17           func = module.get_cached_functions()['GetBadges']
18           result = func(widget).should_invalidate(msg)
19 @@ -38,7 +38,8 @@
20       def test_should_invalidate_good_match_fedbadges(self):
21           widget = self.widget_instance('ralph', self.plugin)
22           # msg = self.get_fedmsg('2016-1fbb1135-681b-4d3b-9a40-d0f6ebd313f4')
23 -         msg = {'topic': 'fedbadges.badge.award', 'msg': {'user': {'username': 'ralph'}}}
24 +         msg = {'topic': 'fedbadges.badge.award',
25 +                'msg': {'user': {'username': 'ralph'}}}
26           module = hubs.widgets.registry[widget.plugin]
27           func = module.get_cached_functions()['GetBadges']
28           result = func(widget).should_invalidate(msg)
29 @@ -47,7 +48,8 @@
30       def test_should_invalidate_good_match_hubswidget(self):
31           widget = self.widget_instance('ralph', self.plugin)
32           # msg = self.get_fedmsg('2016-1fbb1135-681b-4d3b-9a40-d0f6ebd313f4')
33 -         msg = {'topic': 'hubs.widget.update', 'msg': {'widget': {'id': widget.idx + 1}}}
34 +         msg = {'topic': 'hubs.widget.update',
35 +                'msg': {'widget': {'id': widget.idx + 1}}}
36           module = hubs.widgets.registry[widget.plugin]
37           func = module.get_cached_functions()['GetBadges']
38           result = func(widget).should_invalidate(msg)
1 @@ -5,6 +5,7 @@
2   import hubs.tests.test_widgets
3   import hubs.models
4   
5 + 
6   class TestLibrary(hubs.tests.test_widgets.WidgetTest):
7       plugin = 'library'  # The name in hubs.widgets.registry
8   
 1 @@ -1,13 +1,11 @@
 2   from __future__ import unicode_literals
 3   
 4 - import json
 5   import logging
 6   from hashlib import sha256
 7   
 8   import arrow
 9   import markdown
10   import requests
11 - import six
12   
13   from six.moves.urllib_parse import urlencode
14   
1 @@ -1,5 +1,7 @@
2   from __future__ import absolute_import
3   
4 + # flake8:noqa
5 + 
6   from .root import *
7   from .hub import *
8   from .widget import *
1 @@ -75,4 +75,3 @@
2           return flask.abort(400)
3       flask.g.db.commit()
4       return flask.redirect(flask.url_for('hub', name=hub.name))
5 - 
1 @@ -4,7 +4,7 @@
2   import flask
3   import hubs.models
4   
5 - from hubs.app import app, session
6 + from hubs.app import app
7   from .utils import get_hub, login_required, RequestValidator
8   
9   
 1 @@ -3,7 +3,7 @@
 2   import flask
 3   import hubs.models
 4   
 5 - from hubs.app import app, session, OIDC
 6 + from hubs.app import app, OIDC
 7   from .utils import authenticated, is_safe_url
 8   
 9   
10 @@ -49,7 +49,8 @@
11           return_point = default
12   
13       hubs.models.User.get_or_create(
14 -         flask.g.db, username=flask.g.auth.nickname, fullname=flask.g.auth.fullname)
15 +         flask.g.db, username=flask.g.auth.nickname,
16 +         fullname=flask.g.auth.fullname)
17       flask.flash('Login successful', 'success')
18   
19       return flask.redirect(return_point)
 1 @@ -5,7 +5,7 @@
 2   import hubs.models
 3   import hubs.stream
 4   
 5 - from hubs.app import app, session
 6 + from hubs.app import app
 7   from .utils import login_required, get_hub
 8   
 9   
10 @@ -62,16 +62,20 @@
11               dict(notification=notification.__json__(), success=True)
12           )
13   
14 + 
15   @app.route('/<user>/notifications/<int:idx>', methods=['DELETE'])
16   @app.route('/<user>/notifications/<int:idx>/', methods=['DELETE'])
17   @login_required
18   def delete_notifications(user, idx):
19 -     notification = flask.g.db.query(hubs.models.SavedNotification).filter_by(idx=idx).first()
20 +     notification = flask.g.db.query(
21 +         hubs.models.SavedNotification).filter_by(idx=idx).first()
22       if not notification:
23           return flask.abort(400)
24       flask.g.db.delete(notification)
25       flask.g.db.commit()
26       return flask.jsonify(dict(status_code=200))
27 + 
28 + 
29   @app.route('/visit/<visited_hub>/', methods=['GET', 'POST'])
30   @app.route('/visit/<visited_hub>', methods=['GET', 'POST'])
31   @login_required
32 @@ -80,9 +84,8 @@
33   
34       if str(visited_hub) != str(nickname):
35           try:
36 -             vc = hubs.models.VisitCounter.get_or_create(session=flask.g.db,
37 -                                                         username=nickname,
38 -                                                         visited_hub=visited_hub)
39 +             vc = hubs.models.VisitCounter.get_or_create(
40 +                 session=flask.g.db, username=nickname, visited_hub=visited_hub)
41           except ValueError:  # this should never trip
42               # flask will 405 if visited_hub is blank
43               # @login_required forces flask.g.auth to be sets
1 @@ -28,6 +28,7 @@
2       cache.configure(**config.get('fedora-hubs.cache', cache_defaults))
3       return cache
4   
5 + 
6   cache = _get_cache()
7   
8   
1 @@ -69,7 +69,7 @@
2                   for repo in repos
3               ], [])
4               # Reverse-sort by time (newest-first)
5 -             pulls.sort(lambda a, b: cmp(b['timestamp'], a['timestamp']))
6 +             pulls.sort(key=lambda x: x['timestamp'], reverse=True)
7   
8               # Some hints for display
9               len_pulls = len(pulls)
 1 @@ -122,8 +122,7 @@
 2       @classmethod
 3       def from_string(cls, value):
 4           # TODO get this from the fedmsg config.
 5 -         if value in [
 6 -             'irc', 'email', 'android', 'desktop', 'hubs',]:
 7 +         if value in ['irc', 'email', 'android', 'desktop', 'hubs']:
 8               return value
 9           raise ValueError('Invalid FMN context')
10   
 1 @@ -1,7 +1,7 @@
 2   #!/usr/bin/env python
 3   """ Populate the hubs db with lots of data from FAS. """
 4   
 5 - from __future__ import unicode_literals
 6 + from __future__ import unicode_literals, print_function
 7   
 8   import getpass
 9   import socket
10 @@ -14,7 +14,7 @@
11   fedmsg_config = fedmsg.config.load_config()
12   
13   fasclient = fedora.client.fas2.AccountSystem(
14 -     username=raw_input('Your FAS username: '),
15 +     username=input('Your FAS username: '),
16       password=getpass.getpass(),
17   )
18   timeout = socket.getdefaulttimeout()
19 @@ -39,7 +39,7 @@
20   for letter in reversed(sorted(list(set(string.letters.lower())))):
21       session = hubs.models.init(
22           fedmsg_config['hubs.sqlalchemy.uri'], True, True)
23 -     print "Querying FAS for the %r users.. hang on." % letter
24 +     print("Querying FAS for the %r users.. hang on." % letter)
25       request = fasclient.send_request(
26           '/user/list',
27           req_params={'search': '%s*' % letter, 'status': 'active'},
28 @@ -50,7 +50,7 @@
29       for user in users:
30           username = user['username']
31           fullname = user['human_name']
32 -         print "Creating account for %r" % username
33 +         print("Creating account for %r" % username)
34           hubs_user = hubs.models.User.get_or_create(
35               session, username=username, fullname=fullname)
36   
populate.py +132 -90
  1 @@ -35,7 +35,7 @@
  2   
  3   session.commit()
  4   
  5 - ############## Internationalizationteam
  6 + # ############# Internationalizationteam
  7   hub = hubs.models.Hub(name='i18n', archived=True)
  8   session.add(hub)
  9   session.add(hubs.models.HubConfig(
 10 @@ -45,13 +45,14 @@
 11   hub.widgets.append(widget)
 12   widget = hubs.models.Widget(plugin='stats', index=0)
 13   hub.widgets.append(widget)
 14 - widget = hubs.models.Widget(plugin='rules', index=1,
 15 -                             _config=json.dumps({
 16 -                                 'link': 'https://fedoraproject.org/wiki/I18N',
 17 -                                 'schedule_text': None,
 18 -                                 'schedule_link': None,
 19 -                                 'minutes_link': 'https://meetbot.fedoraproject.org/sresults/?group_id=i18n&type=team',
 20 -                             }))
 21 + widget = hubs.models.Widget(
 22 +     plugin='rules', index=1, _config=json.dumps({
 23 +         'link': 'https://fedoraproject.org/wiki/I18N',
 24 +         'schedule_text': None,
 25 +         'schedule_link': None,
 26 +         'minutes_link': 'https://meetbot.fedoraproject.org/sresults/'
 27 +                         '?group_id=i18n&type=team',
 28 +     }))
 29   hub.widgets.append(widget)
 30   
 31   widget = hubs.models.Widget(plugin='meetings', index=2,
 32 @@ -59,16 +60,25 @@
 33   hub.widgets.append(widget)
 34   
 35   # Added a hubs about widget
 36 - widget = hubs.models.Widget(plugin='about', index=3,
 37 -                             _config=json.dumps({
 38 -                                 "text": "I'm a Fedora user, and this is my about widget text!",
 39 -                             }))
 40 - hub.widgets.append(widget)
 41 - 
 42 - widget = hubs.models.Widget(plugin='sticky', index=1, left=True,
 43 -                             _config=json.dumps({
 44 -                                 'text': "<p>The Fedora I18N project works on internationalization (i18n) to support the localization (l10n) of Fedora in many languages. Translation of Fedora software and documentation are handled by the Fedora L10N project.</p> <p>The goals of the Project are to:</p> <ul><li>Develop, package, and maintain applications like input methods for different languages</li> <li>Improve applications and utilities to support and process different languages</li> <li>Quality-assure that existing applications meet i18n standards</li> <li>Support the infrastructure of the Fedora Localization Project</li></ul>",
 45 -                             }))
 46 + widget = hubs.models.Widget(
 47 +     plugin='about', index=3, _config=json.dumps({
 48 +         "text": "I'm a Fedora user, and this is my about widget text!",
 49 +     }))
 50 + hub.widgets.append(widget)
 51 + 
 52 + widget = hubs.models.Widget(
 53 +     plugin='sticky', index=1, left=True, _config=json.dumps({
 54 +         'text': """
 55 + <p>The Fedora I18N project works on internationalization (i18n) to support the
 56 + localization (l10n) of Fedora in many languages. Translation of Fedora software
 57 + and documentation are handled by the Fedora L10N project.</p> <p>The goals of
 58 + the Project are to:</p> <ul><li>Develop, package, and maintain applications
 59 + like input methods for different languages</li> <li>Improve applications and
 60 + utilities to support and process different languages</li> <li>Quality-assure
 61 + that existing applications meet i18n standards</li> <li>Support the
 62 + infrastructure of the Fedora Localization Project</li></ul>
 63 + """,
 64 +     }))
 65   hub.widgets.append(widget)
 66   widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
 67   hub.widgets.append(widget)
 68 @@ -82,7 +92,7 @@
 69   
 70   session.commit()
 71   
 72 - ############## CommOps
 73 + # ############# CommOps
 74   hub = hubs.models.Hub(name='commops')
 75   session.add(hub)
 76   session.add(hubs.models.HubConfig(
 77 @@ -92,17 +102,20 @@
 78   hub.widgets.append(widget)
 79   widget = hubs.models.Widget(plugin='stats', index=0)
 80   hub.widgets.append(widget)
 81 - widget = hubs.models.Widget(plugin='rules', index=1,
 82 -                             _config=json.dumps({
 83 -                                 'link': 'https://fedoraproject.org/wiki/CommOps',
 84 -                                 'schedule_text': None,
 85 -                                 'schedule_link': None,
 86 -                                 'minutes_link': 'http://meetbot.fedoraproject.org/sresults/?group_id=commops&type=team',
 87 -                             }))
 88 + widget = hubs.models.Widget(
 89 +     plugin='rules', index=1, _config=json.dumps({
 90 +         'link': 'https://fedoraproject.org/wiki/CommOps',
 91 +         'schedule_text': None,
 92 +         'schedule_link': None,
 93 +         'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
 94 +                         '?group_id=commops&type=team',
 95 +     }))
 96   hub.widgets.append(widget)
 97   
 98 - widget = hubs.models.Widget(plugin='meetings', index=2,
 99 -                             _config=json.dumps({'calendar': 'commops', 'n_meetings': 4}))
100 + widget = hubs.models.Widget(
101 +     plugin='meetings', index=2, _config=json.dumps({
102 +         'calendar': 'commops', 'n_meetings': 4
103 +     }))
104   hub.widgets.append(widget)
105   
106   # Added a hubs about widget
107 @@ -112,10 +125,12 @@
108                               }))
109   hub.widgets.append(widget)
110   
111 - widget = hubs.models.Widget(plugin='sticky', index=1, left=True,
112 -                             _config=json.dumps({
113 -                                 'text': "Bringing more heat and light to Fedora, so you don't have to choose between 'building things' and 'building communities that build things.'",
114 -                             }))
115 + widget = hubs.models.Widget(
116 +     plugin='sticky', index=1, left=True, _config=json.dumps({
117 +         'text': "Bringing more heat and light to Fedora, so you don't have "
118 +                 "to choose between 'building things' and 'building "
119 +                 "communities that build things.'",
120 +     }))
121   hub.widgets.append(widget)
122   widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
123   hub.widgets.append(widget)
124 @@ -131,7 +146,7 @@
125   
126   session.commit()
127   
128 - ############## Marketing team
129 + # ############# Marketing team
130   hub = hubs.models.Hub(name='marketing')
131   session.add(hub)
132   session.add(hubs.models.HubConfig(
133 @@ -141,30 +156,41 @@
134   hub.widgets.append(widget)
135   widget = hubs.models.Widget(plugin='stats', index=0)
136   hub.widgets.append(widget)
137 - widget = hubs.models.Widget(plugin='rules', index=1,
138 -                             _config=json.dumps({
139 -                                 'link': 'https://fedoraproject.org/wiki/Marketing',
140 -                                 'schedule_text': None,
141 -                                 'schedule_link': None,
142 -                                 'minutes_link': 'http://meetbot.fedoraproject.org/sresults/?group_id=fedora-mktg&type=channel',
143 -                             }))
144 + widget = hubs.models.Widget(
145 +     plugin='rules', index=1, _config=json.dumps({
146 +         'link': 'https://fedoraproject.org/wiki/Marketing',
147 +         'schedule_text': None,
148 +         'schedule_link': None,
149 +         'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
150 +                         '?group_id=fedora-mktg&type=channel',
151 +     }))
152   hub.widgets.append(widget)
153   
154 - widget = hubs.models.Widget(plugin='meetings', index=2,
155 -                             _config=json.dumps({'calendar': 'marketing', 'n_meetings': 4}))
156 + widget = hubs.models.Widget(
157 +     plugin='meetings', index=2, _config=json.dumps({
158 +         'calendar': 'marketing', 'n_meetings': 4
159 +     }))
160   hub.widgets.append(widget)
161   
162   # Added a hubs about widget
163 - widget = hubs.models.Widget(plugin='about', index=3,
164 -                             _config=json.dumps({
165 -                                 "text": "I'm a Fedora user, and this is my about widget text!",
166 -                             }))
167 - hub.widgets.append(widget)
168 - 
169 - widget = hubs.models.Widget(plugin='sticky', index=1, left=True,
170 -                             _config=json.dumps({
171 -                                 'text': "The Fedora Marketing Team develops and executes marketing strategies to promote the usage and support of Fedora worldwide. Through the development of processes and content, this project aims to support the efforts of other Fedora projects to spread Fedora and to provide a central repository of ideas and information that can be used to deliver Fedora to new audiences. We work closely with the Fedora Ambassadors who spread the word about Fedora at events and allow the Fedora Project to interact directly with its existing and prospective users. ",
172 -                             }))
173 + widget = hubs.models.Widget(
174 +     plugin='about', index=3, _config=json.dumps({
175 +         "text": "I'm a Fedora user, and this is my about widget text!",
176 +     }))
177 + hub.widgets.append(widget)
178 + 
179 + widget = hubs.models.Widget(
180 +     plugin='sticky', index=1, left=True, _config=json.dumps({
181 +         'text': """
182 + The Fedora Marketing Team develops and executes marketing strategies to promote
183 + the usage and support of Fedora worldwide. Through the development of processes
184 + and content, this project aims to support the efforts of other Fedora projects
185 + to spread Fedora and to provide a central repository of ideas and information
186 + that can be used to deliver Fedora to new audiences. We work closely with the
187 + Fedora Ambassadors who spread the word about Fedora at events and allow the
188 + Fedora Project to interact directly with its existing and prospective users.
189 + """,
190 +     }))
191   hub.widgets.append(widget)
192   widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
193   hub.widgets.append(widget)
194 @@ -181,7 +207,7 @@
195   
196   session.commit()
197   
198 - ############## Design team
199 + # ############# Design team
200   hub = hubs.models.Hub(name='designteam')
201   session.add(hub)
202   session.add(hubs.models.HubConfig(
203 @@ -191,30 +217,37 @@
204   hub.widgets.append(widget)
205   widget = hubs.models.Widget(plugin='stats', index=0)
206   hub.widgets.append(widget)
207 - widget = hubs.models.Widget(plugin='rules', index=1,
208 -                             _config=json.dumps({
209 -                                 'link': 'https://fedoraproject.org/wiki/Design',
210 -                                 'schedule_text': 'Meetings are every other Tuesday at 16:00 UTC',
211 -                                 'schedule_link': 'https://apps.fedoraproject.org/calendar/design/',
212 -                                 'minutes_link': 'http://meetbot.fedoraproject.org/sresults/?group_id=fedora-design&type=channel',
213 -                             }))
214 + widget = hubs.models.Widget(
215 +     plugin='rules', index=1, _config=json.dumps({
216 +         'link': 'https://fedoraproject.org/wiki/Design',
217 +         'schedule_text': 'Meetings are every other Tuesday at 16:00 UTC',
218 +         'schedule_link': 'https://apps.fedoraproject.org/calendar/design/',
219 +         'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
220 +                         '?group_id=fedora-design&type=channel',
221 +     }))
222   hub.widgets.append(widget)
223   
224 - widget = hubs.models.Widget(plugin='meetings', index=2,
225 -                             _config=json.dumps({'calendar': 'design', 'n_meetings': 4}))
226 + widget = hubs.models.Widget(
227 +     plugin='meetings', index=2, _config=json.dumps({
228 +         'calendar': 'design', 'n_meetings': 4
229 +     }))
230   hub.widgets.append(widget)
231   
232   # Added a hubs about widget
233 - widget = hubs.models.Widget(plugin='about', index=3,
234 -                             _config=json.dumps({
235 -                                 "text": "I'm a Fedora user, and this is my about widget text!",
236 -                             }))
237 + widget = hubs.models.Widget(
238 +     plugin='about', index=3, _config=json.dumps({
239 +         "text": "I'm a Fedora user, and this is my about widget text!",
240 +     }))
241   hub.widgets.append(widget)
242   
243 - widget = hubs.models.Widget(plugin='sticky', index=1, left=True,
244 -                             _config=json.dumps({
245 -                                 'text': "The Design Team is the design group of the Fedora project. Our interests are not only in creating graphics for use by the Fedora community, but also in advocating the use of the creative tools that are a part of Fedora.",
246 -                             }))
247 + widget = hubs.models.Widget(
248 +     plugin='sticky', index=1, left=True, _config=json.dumps({
249 +         'text': """
250 + The Design Team is the design group of the Fedora project. Our interests are
251 + not only in creating graphics for use by the Fedora community, but also in
252 + advocating the use of the creative tools that are a part of Fedora.
253 + """,
254 +     }))
255   hub.widgets.append(widget)
256   widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
257   hub.widgets.append(widget)
258 @@ -232,7 +265,7 @@
259   session.commit()
260   
261   
262 - ############## Infra team
263 + # ############# Infra team
264   hub = hubs.models.Hub(name='infrastructure')
265   session.add(hub)
266   session.add(hubs.models.HubConfig(
267 @@ -242,30 +275,39 @@
268   hub.widgets.append(widget)
269   widget = hubs.models.Widget(plugin='stats', index=0)
270   hub.widgets.append(widget)
271 - widget = hubs.models.Widget(plugin='rules', index=1,
272 -                             _config=json.dumps({
273 -                                 'link': 'https://fedoraproject.org/wiki/Infrastructure',
274 -                                 'schedule_text': 'We meet weekly in #fedora-meeting at 18:00 UTC',
275 -                                 'schedule_link': 'https://apps.fedoraproject.org/calendar/infrastructure/',
276 -                                 'minutes_link': 'http://meetbot.fedoraproject.org/sresults/?group_id=infrastructure&type=team',
277 -                             }))
278 + widget = hubs.models.Widget(
279 +     plugin='rules', index=1, _config=json.dumps({
280 +         'link': 'https://fedoraproject.org/wiki/Infrastructure',
281 +         'schedule_text': 'We meet weekly in #fedora-meeting at 18:00 UTC',
282 +         'schedule_link':
283 +             'https://apps.fedoraproject.org/calendar/infrastructure/',
284 +         'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
285 +                         '?group_id=infrastructure&type=team',
286 +     }))
287   hub.widgets.append(widget)
288   
289 - widget = hubs.models.Widget(plugin='meetings', index=2,
290 -                             _config=json.dumps({'calendar': 'infrastructure', 'n_meetings': 4}))
291 + widget = hubs.models.Widget(
292 +     plugin='meetings', index=2, _config=json.dumps({
293 +         'calendar': 'infrastructure', 'n_meetings': 4
294 +     }))
295   hub.widgets.append(widget)
296   
297   # Added a hubs about widget
298 - widget = hubs.models.Widget(plugin='about', index=3,
299 -                             _config=json.dumps({
300 -                                 "text": "I'm a Fedora user, and this is my about widget text!",
301 -                             }))
302 - hub.widgets.append(widget)
303 - 
304 - widget = hubs.models.Widget(plugin='sticky', index=2, left=True,
305 -                             _config=json.dumps({
306 -                                 'text': "The Infrastructure Team consists of dedicated volunteers and professionals managing the servers, building the tools and utilities, and creating new applications to make Fedora development a smoother process. We're located all over the globe and communicate primarily by IRC and e-mail. ",
307 -                             }))
308 + widget = hubs.models.Widget(
309 +     plugin='about', index=3, _config=json.dumps({
310 +         "text": "I'm a Fedora user, and this is my about widget text!",
311 +     }))
312 + hub.widgets.append(widget)
313 + 
314 + widget = hubs.models.Widget(
315 +     plugin='sticky', index=2, left=True, _config=json.dumps({
316 +         'text': """
317 + The Infrastructure Team consists of dedicated volunteers and professionals
318 + managing the servers, building the tools and utilities, and creating new
319 + applications to make Fedora development a smoother process. We're located all
320 + over the globe and communicate primarily by IRC and e-mail.
321 + """,
322 +     }))
323   hub.widgets.append(widget)
324   widget = hubs.models.Widget(plugin='dummy', index=3, left=True)
325   hub.widgets.append(widget)
 1 @@ -3,7 +3,6 @@
 2   from __future__ import unicode_literals
 3   
 4   import argparse
 5 - import sys
 6   import os
 7   
 8   parser = argparse.ArgumentParser(
 9 @@ -32,7 +31,7 @@
10       os.environ['HUBS_CONFIG'] = config
11   
12   
13 - from hubs.app import app
14 + from hubs.app import app  # noqa
15   
16   app.debug = True
17   app.run(debug=True, host=args.host, port=int(args.port))
 1 @@ -26,8 +26,8 @@
 2       download_url="https://pypi.python.org/pypi/fedora-hubs/",
 3       license='AGPLv3+',
 4       install_requires=get_requirements(),
 5 -     #tests_require=tests_require,
 6 -     #test_suite='nose.collector',
 7 +     # tests_require=tests_require,
 8 +     # test_suite='nose.collector',
 9       packages=find_packages(),
10       include_package_data=True,
11       zip_safe=False,
12 @@ -40,7 +40,7 @@
13       ],
14       entry_points={
15           'moksha.consumer': [
16 -             "cache_invalidator = hubs.backend.consumer:CacheInvalidatorExtraordinaire",
17 +             "cache_invalidator = hubs.backend.consumer:CacheInvalidatorExtraordinaire",  # noqa
18           ],
19       },
20   )
 1 @@ -11,9 +11,7 @@
 2   from __future__ import print_function, unicode_literals
 3   
 4   import argparse
 5 - import os
 6   
 7 - import dogpile.cache
 8   import fedmsg.config
 9   import fedmsg.meta
10   
11 @@ -39,8 +37,8 @@
12           widget = w_instance.module
13           for fn_name, fn_class in widget.get_cached_functions().items():
14               if fn_class(w_instance).is_cached():
15 -                 print('- Widget cached {0} (#{1}) in {2}'.format(
16 -                           w_instance.hub_id, w_instance.idx, w_instance.plugin))
17 +                 print(('- Widget cached {inst.hub_id} (#{inst.idx}) '
18 +                        'in {inst.plugin}').format(inst=w_instance))
19   
20   
21   def do_clean(args):
tox.ini +1 -1
1 @@ -1,5 +1,5 @@
2   [tox]
3 - envlist = py{27,34,35},js,docs
4 + envlist = py{27,34,35},js,docs,lint
5   skipsdist = True
6   
7