Skip to content

Commit

Permalink
Drop support for Python 2 in bodhi.server.
Browse files Browse the repository at this point in the history
Python 2 support goes away upstream in two months, so it is time
to embrace the glorious future.

This change also drops support for pkgdb integration, since the
pkgdb client library does not support Python 3.

Mock imports were moved to be grouped with the stdlib imports as
per PEP-8, since mock is part of the stdlib in Python 3.

fixes #1970
fixes #2759

Signed-off-by: Randy Barlow <[email protected]>
  • Loading branch information
bowlofeggs committed Jan 7, 2019
1 parent b662f73 commit c766843
Show file tree
Hide file tree
Showing 124 changed files with 308 additions and 696 deletions.
6 changes: 0 additions & 6 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ pull_request_rules:
- status-success=f28-flake8
- status-success=f28-pydocstyle
- status-success=f28-python2-unit
- status-success=f28-python2-diff-cover
- status-success=f28-python3-unit
- status-success=f28-python3-diff-cover
- status-success=f29-docs
- status-success=f29-flake8
- status-success=f29-pydocstyle
- status-success=f29-python2-unit
- status-success=f29-python2-diff-cover
- status-success=f29-python3-unit
- status-success=f29-python3-diff-cover
- status-success=pip-docs
- status-success=pip-flake8
- status-success=pip-mypy
- status-success=pip-pydocstyle
- status-success=pip-python2-unit
- status-success=pip-python2-diff-cover
- status-success=pip-python3-unit
- status-success=pip-python3-diff-cover
- status-success=f29-python3-integration
Expand All @@ -46,22 +43,19 @@ pull_request_rules:
- status-success=f28-flake8
- status-success=f28-pydocstyle
- status-success=f28-python2-unit
- status-success=f28-python2-diff-cover
- status-success=f28-python3-unit
- status-success=f28-python3-diff-cover
- status-success=f29-docs
- status-success=f29-flake8
- status-success=f29-pydocstyle
- status-success=f29-python2-unit
- status-success=f29-python2-diff-cover
- status-success=f29-python3-unit
- status-success=f29-python3-diff-cover
- status-success=pip-docs
- status-success=pip-flake8
- status-success=pip-mypy
- status-success=pip-pydocstyle
- status-success=pip-python2-unit
- status-success=pip-python2-diff-cover
- status-success=pip-python3-unit
- status-success=pip-python3-diff-cover
name: default-from-bowlofeggs
Expand Down
4 changes: 1 addition & 3 deletions bodhi/server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright © 2007-2018 Red Hat, Inc. and others.
#
# This file is part of Bodhi.
Expand Down Expand Up @@ -29,7 +28,6 @@
from pyramid.renderers import JSONP
from sqlalchemy import engine_from_config, event
from sqlalchemy.orm import scoped_session, sessionmaker
import six

from bodhi.server import bugs, buildsys
from bodhi.server.config import config as bodhi_config
Expand Down Expand Up @@ -72,7 +70,7 @@ def get_user(request):
from bodhi.server.models import User
userid = request.unauthenticated_userid
if userid is not None:
user = request.db.query(User).filter_by(name=six.text_type(userid)).first()
user = request.db.query(User).filter_by(name=str(userid)).first()
# Why munch? https://github.com/fedora-infra/bodhi/issues/473
return munchify(user.__json__(request=request))

Expand Down
8 changes: 3 additions & 5 deletions bodhi/server/bugs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright © 2013-2017 Red Hat, Inc. and others.
# Copyright © 2013-2018 Red Hat, Inc. and others.
#
# This file is part of Bodhi.
#
Expand All @@ -18,13 +17,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""Defines utilities for accessing Bugzilla."""

from xmlrpc import client as xmlrpc_client
import logging

from collections import namedtuple
from kitchen.text.converters import to_unicode
import bugzilla
import six
from six.moves import xmlrpc_client

from bodhi.server.config import config

Expand Down Expand Up @@ -276,7 +274,7 @@ def update_details(self, bug, bug_entity):
if bug.product == 'Security Response':
bug_entity.parent = True
bug_entity.title = to_unicode(bug.short_desc)
if isinstance(bug.keywords, six.string_types):
if isinstance(bug.keywords, str):
keywords = bug.keywords.split()
else: # python-bugzilla 0.8.0+
keywords = bug.keywords
Expand Down
1 change: 0 additions & 1 deletion bodhi/server/buildsys.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2007-2018 Red Hat, Inc. and others.
#
# This file is part of Bodhi.
Expand Down
7 changes: 2 additions & 5 deletions bodhi/server/captcha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright © 2014-2018 Red Hat, Inc.
#
# This file is part of Bodhi.
Expand All @@ -21,7 +20,6 @@
# Authors: Ralph Bean <[email protected]>
"""Define utilities and a view pertaining to captcha images for unauthenticated users."""

from __future__ import division
import base64
import math
import random
Expand All @@ -31,7 +29,6 @@
from pyramid.httpexceptions import HTTPGone, HTTPNotFound
from pyramid.view import view_config
import cryptography.fernet
import six


def math_generator(plainkey, settings):
Expand Down Expand Up @@ -62,7 +59,7 @@ def math_generator(plainkey, settings):

x, y = int(tokens[0]), int(tokens[2])

value = six.text_type(x + y)
value = str(x + y)
return plainkey, value


Expand Down Expand Up @@ -252,7 +249,7 @@ def decrypt(ciphertext, settings):
secret = settings['captcha.secret']
engine = cryptography.fernet.Fernet(secret)

if isinstance(ciphertext, six.text_type):
if isinstance(ciphertext, str):
ciphertext = ciphertext.encode('utf-8')

try:
Expand Down
Loading

0 comments on commit c766843

Please sign in to comment.