#2218 Drop py2 support for hub/web
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue1942  into  master

file modified
+3 -2
@@ -80,8 +80,9 @@ 

  

  test2:

  	coverage2 erase

- 	PYTHONPATH=hub/.:plugins/hub/.:plugins/builder/.:plugins/cli/.:cli/.:www/lib coverage2 run \

- 	    --source . -m nose

+ 	PYTHONPATH=.:plugins/builder/.:plugins/cli/.:cli/.:www/lib coverage2 run \

+ 	    --source . -m nose tests/test_builder tests/test_cli tests/test_lib \

+ 	    tests/test_plugins/test*builder.py tests/test_plugins/test*cli.py

  	coverage2 report

  	coverage2 html

  	@echo Full coverage report at file://${CURDIR}/htmlcov/py2/index.html

file modified
+1 -1
@@ -121,7 +121,7 @@ 

      parser.add_option("--principal", help=_("specify a Kerberos principal to use"))

      parser.add_option("--krbservice", help=_("specify the Kerberos service name for the hub"))

      parser.add_option("--cert", help=_("specify a SSL cert to use"), metavar="FILE")

-     parser.add_option("--ca", help=SUPPRESS_HELP, metavar="FILE") # FIXME: remove in 1.24

+     parser.add_option("--ca", help=SUPPRESS_HELP, metavar="FILE")  # FIXME: remove in 1.24

      parser.add_option("--runas", help=_("run as the specified user (requires special privileges)"))

      parser.add_option("--user", help=_("specify user"))

      parser.add_option("--password", help=_("specify password"))

file modified
+69 -77
@@ -46,10 +46,8 @@ 

  import zipfile

  

  import rpm

- import six

- import six.moves.xmlrpc_client

- from six.moves import range

- from six.moves.urllib.parse import parse_qs

+ import xmlrpc.client

+ from urllib.parse import parse_qs

  

  import koji

  import koji.auth
@@ -84,7 +82,7 @@ 

  logger = logging.getLogger('koji.hub')

  

  

- NUMERIC_TYPES = tuple(list(six.integer_types) + [float])

+ NUMERIC_TYPES = (int, float)

  

  

  def log_error(msg):
@@ -436,7 +434,7 @@ 

              # handle older base64 encoded data

              xml_request = base64.b64decode(xml_request)

          # note: loads accepts either bytes or string

-         params, method = six.moves.xmlrpc_client.loads(xml_request)

+         params, method = xmlrpc.client.loads(xml_request)

          return params

  

      def getResult(self, raise_fault=True):
@@ -455,8 +453,8 @@ 

          try:

              # If the result is a Fault, then loads will raise it

              # This is normally what we want to happen

-             result, method = six.moves.xmlrpc_client.loads(xml_result)

-         except six.moves.xmlrpc_client.Fault as fault:

+             result, method = xmlrpc.client.loads(xml_result)

+         except xmlrpc.client.Fault as fault:

              if raise_fault:

                  raise

              # Note that you can't really return a fault over xmlrpc, except by
@@ -494,7 +492,7 @@ 

                      # handle older base64 encoded data

                      task['request'] = base64.b64decode(task['request'])

                  # note: loads accepts either bytes or string

-                 task['request'] = six.moves.xmlrpc_client.loads(task['request'])[0]

+                 task['request'] = xmlrpc.client.loads(task['request'])[0]

          return results

  

      def runCallbacks(self, cbtype, old_info, attr, new_val):
@@ -664,7 +662,7 @@ 

          table += '.'

      if event is None:

          return """(%(table)sactive = TRUE)""" % locals()

-     elif isinstance(event, six.integer_types):

+     elif isinstance(event, int):

          return "(%(table)screate_event <= %(event)d AND ( %(table)srevoke_event IS NULL OR " \

                 "%(event)d < %(table)srevoke_event ))" % locals()

      else:
@@ -761,12 +759,12 @@ 

                      data[parent_id] = link

                      break

      if clear:

-         for link in six.itervalues(data):

+         for link in data.values():

              if not link.get('is_update'):

                  link['delete link'] = True

                  link['is_update'] = True

      changed = False

-     for link in six.itervalues(data):

+     for link in data.values():

          if link.get('is_update'):

              changed = True

              break
@@ -776,18 +774,18 @@ 

          return

      # check for duplicate priorities

      pri_index = {}

-     for link in six.itervalues(data):

+     for link in data.values():

          if link.get('delete link'):

              continue

          pri_index.setdefault(link['priority'], []).append(link)

-     for pri, dups in six.iteritems(pri_index):

+     for pri, dups in pri_index.items():

          if len(dups) <= 1:

              continue

          # oops, duplicate entries for a single priority

          dup_ids = [link['parent_id'] for link in dups]

          raise koji.GenericError("Inheritance priorities must be unique (pri %s: %r )" %

                                  (pri, dup_ids))

-     for parent_id, link in six.iteritems(data):

+     for parent_id, link in data.items():

          if not link.get('is_update'):

              continue

          # revoke old values
@@ -795,7 +793,7 @@ 

                                   clauses=['tag_id=%(tag_id)s', 'parent_id = %(parent_id)s'])

          update.make_revoke()

          update.execute()

-     for parent_id, link in six.iteritems(data):

+     for parent_id, link in data.items():

          if not link.get('is_update'):

              continue

          # skip rest if we are just deleting
@@ -980,7 +978,7 @@ 

      tag_id = tag['id']

      pkg = lookup_package(pkginfo, strict=False)

      if not pkg:

-         if not isinstance(pkginfo, six.string_types):

+         if not isinstance(pkginfo, str):

              raise koji.GenericError("Invalid package: %s" % pkginfo)

      if owner is not None:

          owner = get_user(owner, strict=True)['id']
@@ -1177,7 +1175,7 @@ 

          q += """

          AND users.id = %%(userID)i"""

      if pkgID is not None:

-         if isinstance(pkgID, six.integer_types):

+         if isinstance(pkgID, int):

              q += """

              AND package.id = %%(pkgID)i"""

          else:
@@ -1463,7 +1461,7 @@ 

          joins.append('LEFT OUTER JOIN rpmsigs on rpminfo.id = rpmsigs.rpm_id')

      if arch:

          data['arch'] = arch

-         if isinstance(arch, six.string_types):

+         if isinstance(arch, str):

              clauses.append('rpminfo.arch = %(arch)s')

          elif isinstance(arch, (list, tuple)):

              clauses.append('rpminfo.arch IN %(arch)s')
@@ -2165,7 +2163,7 @@ 

              groups.setdefault(grp_id, group)

  

      if incl_pkgs:

-         for group in six.itervalues(groups):

+         for group in groups.values():

              group['packagelist'] = {}

          fields = ('group_id', 'tag_id', 'package', 'blocked', 'type', 'basearchonly', 'requires')

          q = """
@@ -2187,7 +2185,7 @@ 

  

      if incl_reqs:

          # and now the group reqs

-         for group in six.itervalues(groups):

+         for group in groups.values():

              group['grouplist'] = {}

          fields = ('group_id', 'tag_id', 'req_id', 'blocked', 'type', 'is_metapkg', 'name')

          q = """SELECT %s FROM group_req_listing JOIN groups on req_id = id
@@ -2321,7 +2319,7 @@ 

  def rename_channel(old, new):

      """Rename a channel"""

      context.session.assertPerm('admin')

-     if not isinstance(new, six.string_types):

+     if not isinstance(new, str):

          raise koji.GenericError("new channel name must be a string")

      cinfo = get_channel(old, strict=True)

      dup_check = get_channel(new, strict=False)
@@ -2678,7 +2676,7 @@ 

                  os.symlink(relpath, destlink)

              except Exception:

                  log_error('Error linking %s to %s' % (destlink, relpath))

-         for artifact_dir, artifacts in six.iteritems(artifact_dirs):

+         for artifact_dir, artifacts in artifact_dirs.items():

              _write_maven_repo_metadata(artifact_dir, artifacts)

  

      koji.plugin.run_callbacks('postRepoInit', tag=tinfo, with_src=with_src,
@@ -2691,10 +2689,7 @@ 

      # Sort the list so that the highest version number comes last.

      # group_id and artifact_id should be the same for all entries,

      # so we're really only comparing versions.

-     if six.PY3:

-         sort_param = {'key': functools.cmp_to_key(rpm.labelCompare)}

-     else:

-         sort_param = {'cmp': lambda a, b: rpm.labelCompare(a, b)}

+     sort_param = {'key': functools.cmp_to_key(rpm.labelCompare)}

      artifacts = sorted(artifacts, **sort_param)

      artifactinfo = dict(zip(['group_id', 'artifact_id', 'version'], artifacts[-1]))

      artifactinfo['timestamp'] = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
@@ -3100,7 +3095,7 @@ 

      if info:

          if isinstance(info, str):

              clauses.append('build_target.name = %(info)s')

-         elif isinstance(info, six.integer_types):

+         elif isinstance(info, int):

              clauses.append('build_target.id = %(info)i')

          else:

              raise koji.GenericError('invalid type for lookup: %s' % type(info))
@@ -3145,13 +3140,10 @@ 

      create option will fail.

      """

      fields = ('id', 'name')

-     if isinstance(info, six.integer_types):

+     if isinstance(info, int):

          q = """SELECT id,name FROM %s WHERE id=%%(info)d""" % table

      elif isinstance(info, str):

          q = """SELECT id,name FROM %s WHERE name=%%(info)s""" % table

-     elif six.PY2 and isinstance(info, unicode):  # noqa: F821

-         info = koji.fixEncoding(info)

-         q = """SELECT id,name FROM %s WHERE name=%%(info)s""" % table

      else:

          raise koji.GenericError('invalid type for id lookup: %s' % type(info))

      ret = _singleRow(q, locals(), fields, strict=False)
@@ -3284,7 +3276,7 @@ 

  

      # add extra data

      if extra is not None:

-         for key, value in six.iteritems(extra):

+         for key, value in extra.items():

              data = {

                  'tag_id': tag_id,

                  'key': key,
@@ -3342,9 +3334,9 @@ 

                'tag_config.maven_include_all': 'maven_include_all'

                }

      clauses = [eventCondition(event, table='tag_config')]

-     if isinstance(tagInfo, six.integer_types):

+     if isinstance(tagInfo, int):

          clauses.append("tag.id = %(tagInfo)i")

-     elif isinstance(tagInfo, six.string_types):

+     elif isinstance(tagInfo, str):

          clauses.append("tag.name = %(tagInfo)s")

      else:

          raise koji.GenericError('invalid type for tagInfo: %s' % type(tagInfo))
@@ -3592,7 +3584,7 @@ 

      if info is not None:

          if isinstance(info, str):

              clauses.append('name = %(info)s')

-         elif isinstance(info, six.integer_types):

+         elif isinstance(info, int):

              clauses.append('id = %(info)i')

          else:

              raise koji.GenericError('invalid type for lookup: %s' % type(info))
@@ -3889,9 +3881,9 @@ 

      fields = ['id', 'name', 'status', 'usertype']

      if isinstance(userInfo, dict):

          data = userInfo

-     elif isinstance(userInfo, six.integer_types):

+     elif isinstance(userInfo, int):

          data = {'id': userInfo}

-     elif isinstance(userInfo, six.string_types):

+     elif isinstance(userInfo, str):

          data = {'info': userInfo}

          clauses = ['krb_principal = %(info)s OR name = %(info)s']

      else:
@@ -3901,21 +3893,21 @@ 

          clauses = []

          uid = data.get('id')

          if uid is not None:

-             if isinstance(uid, six.integer_types):

+             if isinstance(uid, int):

                  clauses.append('users.id = %(id)i')

              else:

                  raise koji.GenericError('invalid type for userid: %s'

                                          % type(uid))

          username = data.get('name')

          if username:

-             if isinstance(username, six.string_types):

+             if isinstance(username, str):

                  clauses.append('users.name = %(name)s')

              else:

                  raise koji.GenericError('invalid type for username: %s'

                                          % type(username))

          krb_principal = data.get('krb_principal')

          if krb_principal:

-             if isinstance(krb_principal, six.string_types):

+             if isinstance(krb_principal, str):

                  clauses.append('user_krb_principals.krb_principal'

                                 ' = %(krb_principal)s')

              else:
@@ -4031,7 +4023,7 @@ 

              raise koji.GenericError("No user provided")

      fields = ['krb_principal']

      data = {'info': user_info}

-     if isinstance(user_info, six.integer_types):

+     if isinstance(user_info, int):

          joins = []

          clauses = ['user_id = %(info)i']

      elif isinstance(user_info, str):
@@ -4076,7 +4068,7 @@ 

  

      :returns int: build ID

      """

-     if isinstance(X, six.integer_types):

+     if isinstance(X, int):

          return X

      elif isinstance(X, str):

          data = koji.parse_NVR(X)
@@ -4327,7 +4319,7 @@ 

      )

      # we can look up by id or NVRA

      data = None

-     if isinstance(rpminfo, six.integer_types):

+     if isinstance(rpminfo, int):

          data = {'id': rpminfo}

      elif isinstance(rpminfo, str):

          data = koji.parse_NVRA(rpminfo)
@@ -5216,7 +5208,7 @@ 

                }

      clauses = [eventCondition(event, table='host_config')]

  

-     if isinstance(hostInfo, six.integer_types):

+     if isinstance(hostInfo, int):

          clauses.append("host.id = %(hostInfo)i")

      elif isinstance(hostInfo, str):

          clauses.append("host.name = %(hostInfo)s")
@@ -5293,7 +5285,7 @@ 

      fields = ('id', 'name')

      query = """SELECT %s FROM channels

      WHERE """ % ', '.join(fields)

-     if isinstance(channelInfo, six.integer_types):

+     if isinstance(channelInfo, int):

          query += """id = %(channelInfo)i"""

      elif isinstance(channelInfo, str):

          query += """name = %(channelInfo)s"""
@@ -5960,7 +5952,7 @@ 

          import_rpm_file(fn, binfo, rpminfo)

          add_rpm_sig(rpminfo['id'], koji.rip_rpm_sighdr(fn))

      if logs:

-         for key, files in six.iteritems(logs):

+         for key, files in logs.items():

              if not key:

                  key = None

              for relpath in files:
@@ -6253,7 +6245,7 @@ 

          if metadata is None:

              # default to looking for uploaded file

              metadata = 'metadata.json'

-         if not isinstance(metadata, six.string_types):

+         if not isinstance(metadata, str):

              raise koji.GenericError("Invalid metadata value: %r" % metadata)

          if metadata.endswith('.json'):

              # handle uploaded metadata
@@ -6364,7 +6356,7 @@ 

              datetime.datetime.fromtimestamp(float(metadata['build']['end_time'])).isoformat(' ')

          owner = metadata['build'].get('owner', None)

          if owner:

-             if not isinstance(owner, six.string_types):

+             if not isinstance(owner, str):

                  raise koji.GenericError("Invalid owner format (expected username): %s" % owner)

              buildinfo['owner'] = get_user(owner, strict=True)['id']

          self.buildinfo = buildinfo
@@ -6781,14 +6773,14 @@ 

  

      # sanity check rpminfo

      dtypes = (

-         ('name', six.string_types),

-         ('version', six.string_types),

-         ('release', six.string_types),

+         ('name', str),

+         ('version', str),

+         ('release', str),

          ('epoch', (int, type(None))),

-         ('arch', six.string_types),

+         ('arch', str),

          ('payloadhash', str),

          ('size', int),

-         ('buildtime', six.integer_types))

+         ('buildtime', int))

      for field, allowed in dtypes:

          if field not in rpminfo:

              raise koji.GenericError("%s field missing: %r" % (field, rpminfo))
@@ -7808,7 +7800,7 @@ 

                  fields['creator.id = %(editor)i'] = '_created_by'

                  fields['revoker.id = %(editor)i'] = '_revoked_by'

              elif arg == 'after':

-                 if not isinstance(value, six.string_types):

+                 if not isinstance(value, str):

                      value = datetime.datetime.fromtimestamp(value).isoformat(' ')

                  data['after'] = value

                  clauses.append('ev1.time > %(after)s OR ev2.time > %(after)s')
@@ -7824,7 +7816,7 @@ 

                  fields[c_test] = '_created_after_event'

                  fields[r_test] = '_revoked_after_event'

              elif arg == 'before':

-                 if not isinstance(value, six.string_types):

+                 if not isinstance(value, str):

                      value = datetime.datetime.fromtimestamp(value).isoformat(' ')

                  data['before'] = value

                  clauses.append('ev1.time < %(before)s OR ev2.time < %(before)s')
@@ -9289,7 +9281,7 @@ 

          if not pkginfo:

              # for some operations (e.g. adding a new package), the package

              # entry may not exist yet

-             if isinstance(data['package'], six.string_types):

+             if isinstance(data['package'], str):

                  return {'id': None, 'name': data['package']}

              else:

                  raise koji.GenericError("Invalid package: %s" % data['package'])
@@ -9672,7 +9664,7 @@ 

              return False

          groups = koji.auth.get_user_groups(user['id'])

          args = self.str.split()[1:]

-         for group_id, group in six.iteritems(groups):

+         for group_id, group in groups.items():

              for pattern in args:

                  if fnmatch.fnmatch(group, pattern):

                      return True
@@ -10344,7 +10336,7 @@ 

          # we will accept offset and size as strings to work around xmlrpc limits

          offset = koji.decode_int(offset)

          size = koji.decode_int(size)

-         if isinstance(md5sum, six.string_types):

+         if isinstance(md5sum, str):

              # this case is for backwards compatibility

              verify = "md5"

              digest = md5sum
@@ -10990,9 +10982,9 @@ 

          if before:

              if isinstance(before, datetime.datetime):

                  before = calendar.timegm(before.utctimetuple())

-             elif isinstance(before, six.string_types):

+             elif isinstance(before, str):

                  before = koji.util.parseTime(before)

-             elif isinstance(before, six.integer_types):

+             elif isinstance(before, int):

                  pass

              else:

                  raise koji.GenericError('invalid type for before: %s' % type(before))
@@ -11000,9 +10992,9 @@ 

          if after:

              if isinstance(after, datetime.datetime):

                  after = calendar.timegm(after.utctimetuple())

-             elif isinstance(after, six.string_types):

+             elif isinstance(after, str):

                  after = koji.util.parseTime(after)

-             elif isinstance(after, six.integer_types):

+             elif isinstance(after, int):

                  pass

              else:

                  raise koji.GenericError('invalid type for after: %s' % type(after))
@@ -11306,14 +11298,14 @@ 

  

      def getLatestBuilds(self, tag, event=None, package=None, type=None):

          """List latest builds for tag (inheritance enabled)"""

-         if not isinstance(tag, six.integer_types):

+         if not isinstance(tag, int):

              # lookup tag id

              tag = get_tag_id(tag, strict=True)

          return readTaggedBuilds(tag, event, inherit=True, latest=True, package=package, type=type)

  

      def getLatestRPMS(self, tag, package=None, arch=None, event=None, rpmsigs=False, type=None):

          """List latest RPMS for tag (inheritance enabled)"""

-         if not isinstance(tag, six.integer_types):

+         if not isinstance(tag, int):

              # lookup tag id

              tag = get_tag_id(tag, strict=True)

          return readTaggedRPMS(tag, package=package, arch=arch, event=event, inherit=True,
@@ -11414,7 +11406,7 @@ 

              stops = {}

          if jumps is None:

              jumps = {}

-         if not isinstance(tag, six.integer_types):

+         if not isinstance(tag, int):

              # lookup tag id

              tag = get_tag_id(tag, strict=True)

          for mapping in [stops, jumps]:
@@ -11441,7 +11433,7 @@ 

          - buildroot_id

  

          If no build has the given ID, or the build generated no RPMs, an empty list is returned."""

-         if not isinstance(build, six.integer_types):

+         if not isinstance(build, int):

              # lookup build id

              build = self.findBuildID(build, strict=True)

          return self.listRPMs(buildID=build)
@@ -11927,7 +11919,7 @@ 

  

          :returns: dict with repo data (id, state, create_event, time, dist)

          """

-         if isinstance(tag, six.integer_types):

+         if isinstance(tag, int):

              id = tag

          else:

              id = get_tag_id(tag, strict=True)
@@ -12240,8 +12232,8 @@ 

                              # handle older base64 encoded data

                              val = base64.b64decode(val)

                          # note: loads accepts either bytes or string

-                         data, method = six.moves.xmlrpc_client.loads(val)

-                     except six.moves.xmlrpc_client.Fault as fault:

+                         data, method = xmlrpc.client.loads(val)

+                     except xmlrpc.client.Fault as fault:

                          data = fault

                      task[f] = data

              yield task
@@ -12556,7 +12548,7 @@ 

              xmlrpc DateTime value"""

          context.session.assertPerm('admin')

          buildinfo = get_build(build, strict=True)

-         if isinstance(ts, six.moves.xmlrpc_client.DateTime):

+         if isinstance(ts, xmlrpc.client.DateTime):

              # not recommended

              # the xmlrpclib.DateTime class is almost useless

              try:
@@ -13621,7 +13613,7 @@ 

              dest = "%s/%s" % (dir, os.path.basename(fn))

              move_and_symlink(fn, dest)

          if logs:

-             for key, files in six.iteritems(logs):

+             for key, files in logs.items():

                  if key:

                      logdir = "%s/logs/%s" % (dir, key)

                  else:
@@ -13855,7 +13847,7 @@ 

          maven_task_id = maven_results['task_id']

          maven_buildroot_id = maven_results['buildroot_id']

          maven_task_dir = koji.pathinfo.task(maven_task_id)

-         for relpath, files in six.iteritems(maven_results['files']):

+         for relpath, files in maven_results['files'].items():

              dir_maven_info = maven_info

              poms = [f for f in files if f.endswith('.pom')]

              if len(poms) == 0:
@@ -14027,7 +14019,7 @@ 

  

          task_dir = koji.pathinfo.task(results['task_id'])

          # import the build output

-         for relpath, metadata in six.iteritems(results['output']):

+         for relpath, metadata in results['output'].items():

              archivetype = get_archive_type(relpath)

              if not archivetype:

                  # Unknown archive type, fail the build
@@ -14284,9 +14276,9 @@ 

              extra_deps = []

          task_deps = {}

          for dep in extra_deps:

-             if isinstance(dep, six.integer_types):

+             if isinstance(dep, int):

                  task_output = list_task_output(dep, stat=True)

-                 for filepath, filestats in six.iteritems(task_output):

+                 for filepath, filestats in task_output.items():

                      if os.path.splitext(filepath)[1] in ['.log', '.md5', '.sha1']:

                          continue

                      tokens = filepath.split('/')
@@ -14430,7 +14422,7 @@ 

          repodir = koji.pathinfo.repo(repo_id, rinfo['tag_name'])

          workdir = koji.pathinfo.work()

          if not rinfo['dist']:

-             for arch, (uploadpath, files) in six.iteritems(data):

+             for arch, (uploadpath, files) in data.items():

                  archdir = "%s/%s" % (repodir, koji.canonArch(arch))

                  if not os.path.isdir(archdir):

                      raise koji.GenericError("Repo arch directory missing: %s" % archdir)

file modified
+9 -21
@@ -18,8 +18,6 @@ 

  # Authors:

  #       Mike McLean <mikem@redhat.com>

  

- from __future__ import absolute_import, division

- 

  import datetime

  import inspect

  import logging
@@ -31,9 +29,6 @@ 

  import time

  import traceback

  

- import six

- from six.moves import range

- 

  import koji

  import koji.auth

  import koji.db
@@ -52,10 +47,7 @@ 

      def dump_datetime(self, value, write):

          # For backwards compatibility, we return datetime objects as strings

          value = value.isoformat(' ')

-         if six.PY2:

-             self.dump_string(value, write)

-         else:

-             self.dump_unicode(value, write)

+         self.dump_unicode(value, write)

      dispatch[datetime.datetime] = dump_datetime

  

  
@@ -104,7 +96,7 @@ 

  

          Handlers are functions marked with one of the decorators defined in koji.plugin

          """

-         for v in six.itervalues(vars(plugin)):

+         for v in vars(plugin).values():

              if isinstance(v, type):

                  # skip classes

                  continue
@@ -375,9 +367,7 @@ 

          faultString = "server is offline"

      else:

          faultString = msg

-     response = dumps(Fault(faultCode, faultString))

-     if six.PY3:

-         response = response.encode()

+     response = dumps(Fault(faultCode, faultString)).encode()

      headers = [

          ('Content-Length', str(len(response))),

          ('Content-Type', "text/xml"),
@@ -492,7 +482,7 @@ 

          opts['policy'] = dict(config.items('policy'))

      else:

          opts['policy'] = {}

-     for pname, text in six.iteritems(_default_policies):

+     for pname, text in _default_policies.items():

          opts['policy'].setdefault(pname, text)

      # use configured KojiDir

      if opts.get('KojiDir') is not None:
@@ -562,14 +552,14 @@ 

              continue

          alltests.append(koji.policy.findSimpleTests(vars(plugin)))

      policy = {}

-     for pname, text in six.iteritems(opts['policy']):

+     for pname, text in opts['policy'].items():

          # filter/merge tests

          merged = {}

          for tests in alltests:

              # tests can be limited to certain policies by setting a class variable

-             for name, test in six.iteritems(tests):

+             for name, test in tests.items():

                  if hasattr(test, 'policy'):

-                     if isinstance(test.policy, six.string_types):

+                     if isinstance(test.policy, str):

                          if pname != test.policy:

                              continue

                      elif pname not in test.policy:
@@ -724,8 +714,7 @@ 

          start_response('405 Method Not Allowed', headers)

          response = "Method Not Allowed\n" \

                     "This is an XML-RPC server. Only POST requests are accepted."

-         if six.PY3:

-             response = response.encode()

+         response = response.encode()

          headers = [

              ('Content-Length', str(len(response))),

              ('Content-Type', "text/plain"),
@@ -755,8 +744,7 @@ 

                  response = h._wrap_handler(h.handle_upload, environ)

              else:

                  response = h._wrap_handler(h.handle_rpc, environ)

-             if six.PY3:

-                 response = response.encode()

+             response = response.encode()

              headers = [

                  ('Content-Length', str(len(response))),

                  ('Content-Type', "text/xml"),

file modified
+22 -86
@@ -183,6 +183,7 @@ 

  Plugins to the koji command-line interface

  %endif

  

+ %if 0%{py3_support} > 1

  %package hub

  Summary: Koji XMLRPC interface

  Group: Applications/Internet
@@ -197,27 +198,6 @@ 

  %description hub

  koji-hub is the XMLRPC interface to the koji database

  

- %if 0%{py2_support} > 1

- %package -n python2-%{name}-hub

- Summary: Koji XMLRPC interface

- Group: Applications/Internet

- License: LGPLv2 and GPLv2

- # rpmdiff lib (from rpmlint) is GPLv2 (only)

- Requires: httpd

- Requires: mod_wsgi

- %if 0%{?fedora} || 0%{?rhel} >= 7

- Requires: mod_auth_gssapi

- %endif

- Requires: python-psycopg2

- Requires: python2-%{name} = %{version}-%{release}

- # py2 xor py3

- Provides: %{name}-hub-code = %{version}-%{release}

- 

- %description -n python2-%{name}-hub

- koji-hub is the XMLRPC interface to the koji database

- %endif

- 

- %if 0%{py3_support} > 1

  %package -n python%{python3_pkgversion}-%{name}-hub

  Summary: Koji XMLRPC interface

  Group: Applications/Internet
@@ -235,7 +215,6 @@ 

  

  %description -n python%{python3_pkgversion}-%{name}-hub

  koji-hub is the XMLRPC interface to the koji database

- %endif

  

  %package hub-plugins

  Summary: Koji hub plugins
@@ -249,27 +228,6 @@ 

  %description hub-plugins

  Plugins to the koji XMLRPC interface

  

- %if 0%{py2_support} > 1

- %package -n python2-%{name}-hub-plugins

- Summary: Koji hub plugins

- Group: Applications/Internet

- License: LGPLv2

- Requires: python2-%{name}-hub = %{version}-%{release}

- %if 0%{?rhel} < 8

- Requires: python-qpid-proton

- %else

- Requires: python2-qpid-proton

- %endif

- Requires: cpio

- Provides: %{name}-hub-plugins-code = %{version}-%{release}

- Obsoletes: python2-%{name}-sidetag-plugin-hub < %{version}-%{release}

- Provides: python2-%{name}-sidetag-plugin-hub = %{version}-%{release}

- 

- %description -n python2-%{name}-hub-plugins

- Plugins to the koji XMLRPC interface

- %endif

- 

- %if 0%{py3_support} > 1

  %package -n python%{python3_pkgversion}-%{name}-hub-plugins

  Summary: Koji hub plugins

  Group: Applications/Internet
@@ -384,6 +342,7 @@ 

  %description utils

  Utilities for the Koji system

  

+ %if 0%{py3_support} > 1

  %package web

  Summary: Koji Web UI

  Group: Applications/Internet
@@ -397,30 +356,6 @@ 

  %description web

  koji-web is a web UI to the Koji system.

  

- %if 0%{py2_support} > 1

- %package -n python2-%{name}-web

- Summary: Koji Web UI

- Group: Applications/Internet

- License: LGPLv2

- %{?python_provide:%python_provide python2-%{name}-web}

- Requires: httpd

- Requires: mod_wsgi

- %if 0%{?fedora} || 0%{?rhel} >= 7

- Requires: mod_auth_gssapi

- %else

- Requires: mod_auth_kerb

- Requires: python-krbV >= 1.0.13

- %endif

- Requires: python-psycopg2

- Requires: python-cheetah

- Requires: python2-%{name} = %{version}-%{release}

- Provides: %{name}-web-code = %{version}-%{release}

- 

- %description -n python2-%{name}-web

- koji-web is a web UI to the Koji system.

- %endif

- 

- %if 0%{py3_support} > 1

  %package -n python%{python3_pkgversion}-%{name}-web

  Summary: Koji Web UI

  Group: Applications/Internet
@@ -508,6 +443,24 @@ 

  %endif

  %endif

  

+ # in case, we're building only py2, delete all py3 content

+ %if 0%{py3_support} < 1 && 0%{py2_support} > 0

+    rm -rf %{buildroot}%{_datadir}/koji-web

+    rm -rf %{buildroot}%{_datadir}/koji-hub

+    rm -rf %{buildroot}%{_prefix}/lib/koji-hub-plugins

+    rm -f %{buildroot}/etc/httpd/conf.d/kojihub.conf

+    rm -f %{buildroot}/etc/httpd/conf.d/kojiweb.conf

+    rm -f %{buildroot}/etc/koji-hub/hub.conf

+    rm -f %{buildroot}/etc/koji-hub/plugins/protonmsg.conf

+    rm -f %{buildroot}/etc/koji-hub/plugins/rpm2maven.conf

+    rm -f %{buildroot}/etc/koji-hub/plugins/save_failed_tree.conf

+    rm -f %{buildroot}/etc/koji-hub/plugins/sidetag.conf

+    rm -f %{buildroot}/etc/kojiweb/web.conf

+    rm -f %{buildroot}%{_prefix}/lib/systemd/system/koji-sweep-db.service

+    rm -f %{buildroot}%{_prefix}/lib/systemd/system/koji-sweep-db.timer

+    rm -f %{buildroot}%{_prefix}/sbin/koji-sweep-db

+ %endif

+ 

  %clean

  rm -rf $RPM_BUILD_ROOT

  
@@ -545,6 +498,7 @@ 

  #%%config(noreplace) %%{_sysconfdir}/koji/plugins/*.conf

  %endif

  

+ %if 0%{py3_support} > 1

  %files hub

  %config(noreplace) /etc/httpd/conf.d/kojihub.conf

  %dir /etc/koji-hub
@@ -556,27 +510,14 @@ 

  %{_unitdir}/koji-sweep-db.timer

  %endif

  

- %if 0%{py2_support} > 1

- %files -n python2-%{name}-hub

- %{_datadir}/koji-hub/*.py*

- %endif

- 

- %if 0%{py3_support} > 1

  %files -n python%{python3_pkgversion}-%{name}-hub

  %{_datadir}/koji-hub/*.py

  %{_datadir}/koji-hub/__pycache__

- %endif

  

  %files hub-plugins

  %dir /etc/koji-hub/plugins

  %config(noreplace) /etc/koji-hub/plugins/*.conf

  

- %if 0%{py2_support} > 1

- %files -n python2-%{name}-hub-plugins

- %{_prefix}/lib/koji-hub-plugins/*.py*

- %endif

- 

- %if 0%{py3_support} > 1

  %files -n python%{python3_pkgversion}-%{name}-hub-plugins

  %{_prefix}/lib/koji-hub-plugins/*.py

  %{_prefix}/lib/koji-hub-plugins/__pycache__
@@ -612,18 +553,13 @@ 

  %config(noreplace) /etc/koji-shadow/koji-shadow.conf

  %{_sbindir}/koji-sidetag-cleanup

  

+ %if 0%{py3_support} > 1

  %files web

  %dir /etc/kojiweb

  %config(noreplace) /etc/kojiweb/web.conf

  %config(noreplace) /etc/httpd/conf.d/kojiweb.conf

  %dir /etc/kojiweb/web.conf.d

  

- %if 0%{py2_support} > 1

- %files -n python2-%{name}-web

- %{_datadir}/koji-web

- %endif

- 

- %if 0%{py3_support} > 1

  %files -n python%{python3_pkgversion}-%{name}-web

  %{_datadir}/koji-web

  %endif

file modified
-2
@@ -5,8 +5,6 @@ 

  # Authors:

  #     Mike Bonnet <mikeb@redhat.com>

  

- from __future__ import absolute_import

- 

  import logging

  

  from koji.plugin import callback, callbacks, ignore_error

@@ -5,8 +5,6 @@ 

  # Authors:

  #     Mike Bonnet <mikeb@redhat.com>

  

- from __future__ import absolute_import

- 

  import json

  import logging

  import random

@@ -5,8 +5,6 @@ 

  # Authors:

  #     Mike Bonnet <mikeb@redhat.com>

  

- from __future__ import absolute_import

- 

  import fnmatch

  import os

  import subprocess

@@ -3,8 +3,6 @@ 

  # plugin has a config file.  This hub plugin has no config file.

  

  

- from __future__ import absolute_import

- 

  import random

  import sys

  

@@ -1,5 +1,3 @@ 

- from __future__ import absolute_import

- 

  import sys

  

  import koji

@@ -1,8 +1,4 @@ 

- from __future__ import absolute_import

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import mock

  

  import koji

@@ -1,8 +1,4 @@ 

- from __future__ import absolute_import

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import mock

  

  import koji

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import copy

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  from nose.tools import eq_

  

  import kojihub

@@ -1,11 +1,7 @@ 

- from __future__ import absolute_import

  import mock

  import os

  import shutil

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import koji.policy

  import kojihub

@@ -1,4 +1,3 @@ 

- from __future__ import absolute_import

  import copy

  import json

  import mock
@@ -6,10 +5,8 @@ 

  import os.path

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

+ 

  import koji

  import koji.util

  import kojihub

@@ -1,4 +1,3 @@ 

- from __future__ import absolute_import

  import copy

  import json

  import mock
@@ -6,10 +5,8 @@ 

  import os.path

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

+ 

  import koji

  import koji.util

  import kojihub

@@ -1,10 +1,7 @@ 

  # coding: utf-8

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

+ 

  import koji

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import kojihub

  import time

  from koji import GenericError

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,8 +1,4 @@ 

- from __future__ import absolute_import

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import json

  import mock

  import os

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,10 +1,6 @@ 

  # coding: utf-8

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,8 +1,5 @@ 

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,8 +1,5 @@ 

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,13 +1,9 @@ 

- from __future__ import absolute_import

  import mock

  import os

  import os.path

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,5 +1,3 @@ 

- from __future__ import absolute_import

- 

  import mock

  

  from .utils import DBQueryTestCase

@@ -1,10 +1,6 @@ 

- from __future__ import absolute_import

  import mock

  import os

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,13 +1,9 @@ 

- from __future__ import absolute_import

  

  import os

  

  import mock

  

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  import koji.db

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,12 +1,8 @@ 

- from __future__ import absolute_import

  import mock

  import os

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,8 +1,5 @@ 

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,5 +1,3 @@ 

- from __future__ import absolute_import

- 

  import koji

  import kojihub

  from .utils import DBQueryTestCase

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,12 +1,8 @@ 

- from __future__ import absolute_import

  import os

  import mock

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  from koji import GenericError

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import hashlib

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  from koji import GenericError

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  import koji

  import kojihub

  

@@ -1,12 +1,8 @@ 

- from __future__ import absolute_import

  import copy

  import mock

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,12 +1,8 @@ 

- from __future__ import absolute_import

  import mock

  import os

  import shutil

  import tempfile

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,4 +1,3 @@ 

- from __future__ import absolute_import

  import mock

  from .utils import DBQueryTestCase

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,11 +1,7 @@ 

- from __future__ import absolute_import

  

  import mock

  

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,4 +1,3 @@ 

- from __future__ import absolute_import

  import mock

  

  import koji

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

file modified
+1 -5
@@ -1,10 +1,6 @@ 

- from __future__ import absolute_import

  import mock

  

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,11 +1,7 @@ 

- from __future__ import absolute_import

  import copy

  import mock

  import os

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import koji

  import kojihub

@@ -1,10 +1,6 @@ 

- from __future__ import absolute_import

  import mock

  

- try:

-     import unittest2 as unittest

- except ImportError:

-     import unittest

+ import unittest

  

  import kojihub

  

@@ -1,9 +1,5 @@ 

- from __future__ import absolute_import

  import mock

- try: