#19 Drop Python 2.6 support, update tox environments
Merged 4 years ago by adamwill. Opened 4 years ago by adamwill.

file modified
+5 -5
@@ -56,16 +56,16 @@ 

          logger.debug("Release instance: %s", rel)

          if isinstance(rel, fedfind.release.Pungi4Release):

              if not rel.status in fedfind.const.PUNGI_SUCCESS:

-                 sys.exit("Compose {0} failed, or not yet complete!".format(rel))

+                 sys.exit("Compose {} failed, or not yet complete!".format(rel))

          logger.info("Finding images for: %s %s", rel.dist, rel.version)

      except fedfind.exceptions.CidMatchError as err:

-         sys.exit("Compose ID {0} of discovered compose at {1} does not match specified compose ID "

-                  "{2}! Please report a bug.".format(err.release.cid, err.release.location,

+         sys.exit("Compose ID {} of discovered compose at {} does not match specified compose ID "

+                  "{}! Please report a bug.".format(err.release.cid, err.release.location,

                                                      args.composeid))

      except fedfind.exceptions.UnsupportedComposeError as err:

-         sys.exit("Compose is unsupported. {0}".format(str(err)))

+         sys.exit("Compose is unsupported. {}".format(str(err)))

      except ValueError as err:

-         sys.exit("Invalid arguments. {0}".format(str(err)))

+         sys.exit("Invalid arguments. {}".format(str(err)))

      if args.generic_url:

          print(rel.https_url_generic)

          sys.exit()

file modified
+2 -2
@@ -60,7 +60,7 @@ 

          super(UrlMatchError, self).__init__()

  

      def __str__(self):

-         tmpl = "URL mismatch! URL: {0} Class: {1} Location: {2}"

+         tmpl = "URL mismatch! URL: {} Class: {} Location: {}"

          return tmpl.format(self.url, self.release.__class__.__name__, self.release.location)

  

  
@@ -74,7 +74,7 @@ 

          super(CidMatchError, self).__init__()

  

      def __str__(self):

-         tmpl = "Compose ID mismatch! Requested CID: {0} Class: {1} Class CID: {2}"

+         tmpl = "Compose ID mismatch! Requested CID: {} Class: {} Class CID: {}"

          return tmpl.format(self.cid, self.release.__class__.__name__, self.release.cid)

  

  # vim: set textwidth=100 ts=8 et sw=4:

file modified
+10 -10
@@ -58,7 +58,7 @@ 

      if not os.path.exists(CACHEDIR):

          os.makedirs(CACHEDIR)

      if not os.access(CACHEDIR, os.W_OK):

-         raise OSError("Write access to {0} denied!".format(CACHEDIR))

+         raise OSError("Write access to {} denied!".format(CACHEDIR))

  except (IOError, OSError) as err:

      logger.warning("Cannot use permanent cache! Using temporary cache, valid only for process")

      logger.warning("Error: %s", err)
@@ -90,7 +90,7 @@ 

              dateobj = datetime.datetime.strptime(str(value), '%Y%m%d')

          except ValueError:

              if fail_raise:

-                 newerr = "{0} is not a valid date.".format(value)

+                 newerr = "{} is not a valid date.".format(value)

                  raise ValueError(newerr)

              else:

                  return False
@@ -118,7 +118,7 @@ 

              logger.debug("Error: %s", err)

              tries -= 1

      if not resp:

-         raise ValueError("urlopen_retries: Failed to open {0}!".format(url))

+         raise ValueError("urlopen_retries: Failed to open {}!".format(url))

      return resp

  

  def download_json(url):
@@ -142,7 +142,7 @@ 

          except (ValueError, URLError, HTTPError):

              return False

      else:

-         raise ValueError("Invalid or unhandled URL! URL: {0}".format(url))

+         raise ValueError("Invalid or unhandled URL! URL: {}".format(url))

  

  def get_size(url):

      """Get the size of URL (Content-Length header for HTTP). Currently
@@ -220,7 +220,7 @@ 

          if '-' in typ and typ.replace('-', '.') in filename:

              return typ

          # Others are more token-y.

-         elif "-{0}-".format(typ) in filename:

+         elif "-{}-".format(typ) in filename:

              return typ

      # Sometimes we have to be a bit more relaxed.

      for typ in types:
@@ -460,7 +460,7 @@ 

      # Normalize and check cid

      cid = find_cid(origcid)

      if not cid:

-         raise ValueError("{0} does not appear to be a valid Pungi 4 Fedora "

+         raise ValueError("{} does not appear to be a valid Pungi 4 Fedora "

                           "compose ID!".format(origcid))

      # Writing a truly generic compose ID parser is pretty tricky. See

      # https://github.com/release-engineering/productmd/issues/77
@@ -596,7 +596,7 @@ 

      specify. Uses PDC.

      """

      short = short.lower()

-     params = {'release': "{0}-{1}".format(short, release), 'compose_label': label}

+     params = {'release': "{}-{}".format(short, release), 'compose_label': label}

      res = pdc_query('composes', params)

      if res:

          return res[0]['compose_id']
@@ -737,7 +737,7 @@ 

      # Determine the URL

      if flist not in ('fedora', 'alt', 'archive'):

          raise ValueError("_get_filelist: must be fedora, archive or alt!")

-     fname = 'imagelist-{0}'.format(flist)

+     fname = 'imagelist-{}'.format(flist)

      url = '/'.join((fedfind.const.HTTPS_DL, flist, fname))

      logger.debug("_get_filelist: url is %s", url)

  
@@ -757,8 +757,8 @@ 

          modified = resp.headers['last-modified']

      except ValueError:

          if cachefh:

-             logger.warning("Could not access image list {0}! Using cached "

-                            "copy. Cache may be outdated!")

+             logger.warning("Could not access image list %s at %s! Using cached "

+                            "copy. Cache may be outdated!", flist, url)

              if record:

                  record['downfail'] = True

                  record['cache'] = True

file modified
+81 -81
@@ -84,7 +84,7 @@ 

          if dist not in ("FedoraRespin", "Fedora"):

              raise fedfind.exceptions.UnsupportedComposeError(

                  "get_release(): fedfind does not support composes "

-                 "like {0} as they contain no images".format(cid))

+                 "like {} as they contain no images".format(cid))

  

      # Atomic stable nightly composes, 'Fedora-Atomic' shortname

      if dist == 'Fedora-Atomic':
@@ -130,7 +130,7 @@ 

              return (dist, release, '', '', 0)

          return (dist, release, 'Production', date, int(respin))

      else:

-         raise ValueError("get_release(): could not parse compose ID {0}!".format(cid))

+         raise ValueError("get_release(): could not parse compose ID {}!".format(cid))

  

  def _parse_url(url):

      """Handle a URL if specified. If this looks like the URL for
@@ -230,7 +230,7 @@ 

      # Pungi 4

  #        if int(release) > 23:

  #            return Pungi4Mirror(

- #                '/fedora/linux/releases/{0}'.format(str(release)))

+ #                '/fedora/linux/releases/{}'.format(str(release)))

  

      if int(release) < 7:

          return CoreRelease(release)
@@ -392,7 +392,7 @@ 

          else:

              # this should very rarely happen, but we can't reasonably

              # know what to do if it does

-             raise ValueError('get_release: {0} as dist and {1} as milestone are ambiguous! Cannot '

+             raise ValueError('get_release: {} as dist and {} as milestone are ambiguous! Cannot '

                               'be sure what was meant.'.format(dist, milestone))

      return (dist, milestone)

  
@@ -581,7 +581,7 @@ 

              if url.startswith(fedfind.const.KNOWN_PREFIXES):

                  return Pungi4Release(url)

              else:

-                 raise ValueError("Unexpected URL {0}, expected to start with one of {1}".format(

+                 raise ValueError("Unexpected URL {}, expected to start with one of {}".format(

                      url, ' '.join(fedfind.const.KNOWN_PREFIXES)))

      elif cid:

          (dist, release, milestone, compose, respin) = _parse_cid(cid)
@@ -667,7 +667,7 @@ 

          # Production - the location for the compose on the unmirrored

          # kojipkgs server

          if not label:

-             label = "{0}-{1}.{2}".format(milestone, compose, respin)

+             label = "{}-{}.{}".format(milestone, compose, respin)

          if not cid:

              # We may actually have a compose ID already on one path:

              # if the user called us with a compose ID and promote=True
@@ -678,8 +678,8 @@ 

              (dist, release, milestone, compose, respin) = _parse_cid(cid)

              return Production(release, compose, respin)

          else:

-             raise ValueError("get_release(): could not find release for {0}, "

-                              "{1}, {2}".format(release, milestone, compose))

+             raise ValueError("get_release(): could not find release for {}, "

+                              "{}, {}".format(release, milestone, compose))

  

      # At this point we've handled all composes that we can. If compose

      # is still set, this has to be an error.
@@ -706,12 +706,12 @@ 

          self.compose = str(compose).upper()

          self.version = self.release

          if self.milestone:

-             self.version += ' {0}'.format(self.milestone)

+             self.version += ' {}'.format(self.milestone)

          if self.compose:

-             self.version += ' {0}'.format(self.compose)

+             self.version += ' {}'.format(self.compose)

          try:

              if self.respin:

-                 self.version += '.{0}'.format(self.respin)

+                 self.version += '.{}'.format(self.respin)

          except AttributeError:

              # some classes have no respin

              pass
@@ -720,11 +720,11 @@ 

          self.dist = "Fedora"

  

      def __repr__(self):

-         return "{0}(release='{1}', milestone='{2}', compose='{3}')".format(

+         return "{}(release='{}', milestone='{}', compose='{}')".format(

              self.__class__, self.release, self.milestone, self.compose)

  

      def __str__(self):

-         return "{0} {1}".format(self.__class__.__name__, self.version)

+         return "{} {}".format(self.__class__.__name__, self.version)

  

      @abc.abstractproperty

      def previous_release(self):
@@ -864,9 +864,9 @@ 

                      # add a URL key (save consumers having to do this

                      # work themselves)

                      if imgdict.get('alt', False):

-                         imgdict['url'] = "{0}/{1}".format(self.alt_location, imgdict['path'])

+                         imgdict['url'] = "{}/{}".format(self.alt_location, imgdict['path'])

                      else:

-                         imgdict['url'] = "{0}/{1}".format(self.location, imgdict['path'])

+                         imgdict['url'] = "{}/{}".format(self.location, imgdict['path'])

                      # add a direct_url key, again for consumer ease

                      if imgdict['url'].startswith(fedfind.const.HTTPS):

                          imgdict['direct_url'] = imgdict['url'].replace(
@@ -940,16 +940,16 @@ 

          if self._relnum < 17:

              split = False

          if self._relnum > 23:

-             url = '{0}/{1}/source/tree/Packages/'.format(self.location, tree)

+             url = '{}/{}/source/tree/Packages/'.format(self.location, tree)

          elif self._relnum > 6:

-             url = '{0}/{1}/source/SRPMS/'.format(self.location, tree)

+             url = '{}/{}/source/SRPMS/'.format(self.location, tree)

          elif self._relnum > 4:

-             url = '{0}/source/SRPMS/'.format(self.location)

+             url = '{}/source/SRPMS/'.format(self.location)

          else:

-             url = '{0}/SRPMS/'.format(self.location)

+             url = '{}/SRPMS/'.format(self.location)

          if split:

              for i in initials:

-                 suburl = '{0}{1}/'.format(url, i)

+                 suburl = '{}{}/'.format(url, i)

                  index = fedfind.helpers.urlopen_retries(suburl)

                  text += index.read().decode('utf-8')

          else:
@@ -1006,10 +1006,10 @@ 

          self._pdccid = ""

  

      def __repr__(self):

-         return "{0}(location='{1}')".format(self.__class__, self.location)

+         return "{}(location='{}')".format(self.__class__, self.location)

  

      def __str__(self):

-         return "{0} {1}".format(self.__class__.__name__, self.location)

+         return "{} {}".format(self.__class__.__name__, self.location)

  

      @property

      def location(self):
@@ -1042,7 +1042,7 @@ 

      @cached_property

      def https_url_generic(self):

          """Everything tree is 'generic' for Pungi 4."""

-         return "{0}/{1}".format(self.location, "Everything")

+         return "{}/{}".format(self.location, "Everything")

  

      @property

      def status(self):
@@ -1082,9 +1082,9 @@ 

              return self._metadata

          elif self.exists:

              try:

-                 url = "{0}{1}".format(self._checkloc, "/metadata/composeinfo.json")

+                 url = "{}{}".format(self._checkloc, "/metadata/composeinfo.json")

                  metadata['composeinfo'] = fedfind.helpers.download_json(url)

-                 url = "{0}{1}".format(self._checkloc, "/metadata/images.json")

+                 url = "{}{}".format(self._checkloc, "/metadata/images.json")

                  metadata['images'] = fedfind.helpers.download_json(url)

                  if done:

                      self._metadata = metadata
@@ -1104,7 +1104,7 @@ 

                  if not self._pdccid:

                      # intentionally trigger except block

                      raise ValueError("no pdccid")

-                 origmd = fedfind.helpers.pdc_query('compose-images/{0}'.format(self._pdccid))

+                 origmd = fedfind.helpers.pdc_query('compose-images/{}'.format(self._pdccid))

                  # we should also be able to retrieve the original

                  # composeinfo dict, but I can't find that at all...

              except ValueError:
@@ -1212,7 +1212,7 @@ 

          """

          if self._version:

              return self._version

-         distsep = "{0}-".format(self.dist)

+         distsep = "{}-".format(self.dist)

          return self.cid.split(distsep)[1]

  

      @property
@@ -1333,9 +1333,9 @@ 

          try:

              idx = complist.index(self.cid)

          except IndexError:

-             raise ValueError("Could not find previous compose for {0}".format(self))

+             raise ValueError("Could not find previous compose for {}".format(self))

          if idx == 0:

-             raise IndexError("{0} is the first compose of its type for this release!".format(self))

+             raise IndexError("{} is the first compose of its type for this release!".format(self))

          return get_release(cid=complist[idx-1])

  

      def get_package_nevras_pdc(self, packages):
@@ -1360,7 +1360,7 @@ 

          verdict = dict((package, '') for package in packages)

          params = [('compose', self.cid), ('arch', 'src')]

          for package in packages:

-             params.append(('name', '^{0}$'.format(package)))

+             params.append(('name', '^{}$'.format(package)))

          res = fedfind.helpers.pdc_query('rpms', params)

          if not res:

              logger.warning("get_package_nevras_pdc: No results found in PDC for compose %s! "
@@ -1410,7 +1410,7 @@ 

              # productmd ComposeInfo class has a create_compose_id,

              # but it seems like more work to jump through the hoops

              # to instantiate that than it is to reproduce it...

-             testcid = "Fedora-{0}-{1}.n.{2}".format(self.release, date, respin)

+             testcid = "Fedora-{}-{}.n.{}".format(self.release, date, respin)

              # we use get_release_cid not self.__class__ because the

              # params are different for the children classes

              test = get_release(cid=testcid)
@@ -1419,7 +1419,7 @@ 

                  return test

          logger.setLevel(loglevel)

          raise ValueError("Could not find previous compose for "

-                          "{0}".format(self))

+                          "{}".format(self))

  

  

  class RawhideNightly(OldPreviousReleaseMixin, Pungi4Release):
@@ -1427,7 +1427,7 @@ 

      def __init__(self, compose, respin=0, cid=None):

          compose = str(compose)

          respin = str(respin)

-         path = "rawhide/Fedora-Rawhide-{0}.n.{1}/compose".format(compose, respin)

+         path = "rawhide/Fedora-Rawhide-{}.n.{}/compose".format(compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(RawhideNightly, self).__init__(url, release="Rawhide", milestone='', compose=compose,

                                               respin=respin, typ="nightly", cid=cid)
@@ -1454,7 +1454,7 @@ 

      def __init__(self, compose, respin=0, cid=None):

          compose = str(compose)

          respin = str(respin)

-         path = "Fedora-Modular-Rawhide-{0}.n.{1}/compose".format(compose, respin)

+         path = "Fedora-Modular-Rawhide-{}.n.{}/compose".format(compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(RawhideModularNightly, self).__init__(

              url, release="Rawhide", milestone='', compose=compose,
@@ -1475,7 +1475,7 @@ 

          """Server tree is 'generic' for modular composes at present,

          there is no Everything tree.

          """

-         return "{0}/{1}".format(self.location, "Server")

+         return "{}/{}".format(self.location, "Server")

  

  

  class BikeshedModularNightly(Pungi4Release):
@@ -1486,7 +1486,7 @@ 

      def __init__(self, compose, respin=0, cid=None):

          compose = str(compose)

          respin = str(respin)

-         path = "Fedora-Modular-Bikeshed-{0}.n.{1}/compose".format(compose, respin)

+         path = "Fedora-Modular-Bikeshed-{}.n.{}/compose".format(compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(BikeshedModularNightly, self).__init__(

              url, release="Bikeshed", milestone='', compose=compose,
@@ -1507,7 +1507,7 @@ 

          """Server tree is 'generic' for modular composes at present,

          there is no Everything tree.

          """

-         return "{0}/{1}".format(self.location, "Server")

+         return "{}/{}".format(self.location, "Server")

  

  

  class BranchedNightly(OldPreviousReleaseMixin, Pungi4Release):
@@ -1516,7 +1516,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "branched/Fedora-{0}-{1}.n.{2}/compose".format(release, compose, respin)

+         path = "branched/Fedora-{}-{}.n.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(BranchedNightly, self).__init__(

              url, release=release, milestone="Branched", compose=compose,
@@ -1542,7 +1542,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "Fedora-Modular-{0}-{1}.n.{2}/compose".format(release, compose, respin)

+         path = "Fedora-Modular-{}-{}.n.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(BranchedModularNightly, self).__init__(

              url, release=release, milestone="Branched", compose=compose,
@@ -1570,7 +1570,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "twoweek/Fedora-Atomic-{0}-{1}.{2}/compose".format(release, compose, respin)

+         path = "twoweek/Fedora-Atomic-{}-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(AtomicNightly, self).__init__(

              url, release=release, milestone="Nightly", compose=compose,
@@ -1611,7 +1611,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "cloud/Fedora-Cloud-{0}-{1}.{2}/compose".format(release, compose, respin)

+         path = "cloud/Fedora-Cloud-{}-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(CloudNightly, self).__init__(

              url, release=release, milestone="Nightly", compose=compose,
@@ -1643,7 +1643,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "container/Fedora-Docker-{0}-{1}.{2}/compose".format(release, compose, respin)

+         path = "container/Fedora-Docker-{}-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(DockerNightly, self).__init__(

              url, release=release, milestone="Nightly", compose=compose,
@@ -1672,7 +1672,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "container/Fedora-Container-{0}-{1}.{2}/compose".format(release, compose, respin)

+         path = "container/Fedora-Container-{}-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(ContainerNightly, self).__init__(

              url, release=release, milestone="Nightly", compose=compose,
@@ -1702,7 +1702,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "iot/Fedora-IoT-{0}-{1}.{2}/compose".format(release, compose, respin)

+         path = "iot/Fedora-IoT-{}-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(IoTNightly, self).__init__(

              url, release=release, milestone="Nightly", compose=compose,
@@ -1737,7 +1737,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "updates/Fedora-{0}-updates-{1}.{2}/compose".format(release, compose, respin)

+         path = "updates/Fedora-{}-updates-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(Updates, self).__init__(

              url, release=release, milestone="Updates", compose=compose,
@@ -1772,7 +1772,7 @@ 

          release = str(release)

          compose = str(compose)

          respin = str(respin)

-         path = "updates/Fedora-{0}-updates-testing-{1}.{2}/compose".format(release, compose, respin)

+         path = "updates/Fedora-{}-updates-testing-{}.{}/compose".format(release, compose, respin)

          url = '/'.join((fedfind.const.NIGHTLY_BASE, path))

          super(UpdatesTesting, self).__init__(

              url, release=release, milestone="Updates-testing", compose=compose,
@@ -1827,7 +1827,7 @@ 

          _version in init as that would cause remote trips, do it here

          as a property.

          """

-         return "{0} {1} {2}.{3}".format(self.release, self.milestone, self.compose, self.respin)

+         return "{} {} {}.{}".format(self.release, self.milestone, self.compose, self.respin)

  

  

  class ModularProduction(Pungi4Release):
@@ -1854,7 +1854,7 @@ 

          _version in init as that would cause remote trips, do it here

          as a property.

          """

-         return "{0} Modular {1} {2}.{3}".format(

+         return "{} Modular {} {}.{}".format(

              self.release, self.milestone, self.compose, self.respin)

  

  
@@ -1873,9 +1873,9 @@ 

          milestone = str(milestone)

          compose = str(compose)

          respin = str(respin)

-         label = "{0}-{1}.{2}".format(milestone, compose, respin)

-         version = "{0} {1} {2}.{3}".format(release, milestone, compose, respin)

-         url = '{0}/alt/stage/{1}_{2}'.format(fedfind.const.HTTPS_DL, release, label)

+         label = "{}-{}.{}".format(milestone, compose, respin)

+         version = "{} {} {}.{}".format(release, milestone, compose, respin)

+         url = '{}/alt/stage/{}_{}'.format(fedfind.const.HTTPS_DL, release, label)

          super(Compose, self).__init__(

              url, release=release, milestone=milestone, compose=compose,

              respin=respin, label=label, typ="production", version=version, cid=cid)
@@ -1897,9 +1897,9 @@ 

          milestone = str(milestone)

          compose = str(compose)

          respin = str(respin)

-         label = "{0}-{1}.{2}".format(milestone, compose, respin)

-         version = "{0} Modular {1} {2}.{3}".format(release, milestone, compose, respin)

-         url = '{0}/alt/stage/{1}_Modular_{2}'.format(fedfind.const.HTTPS_DL, release, label)

+         label = "{}-{}.{}".format(milestone, compose, respin)

+         version = "{} Modular {} {}.{}".format(release, milestone, compose, respin)

+         url = '{}/alt/stage/{}_Modular_{}'.format(fedfind.const.HTTPS_DL, release, label)

          super(ModularCompose, self).__init__(

              url, release=release, milestone=milestone, compose=compose,

              respin=respin, label=label, typ="production", version=version, cid=cid)
@@ -1925,13 +1925,13 @@ 

      """

      def __init__(self, path, **kwargs):

          self._basepath = path.rstrip('/')

-         super(Pungi4Mirror, self).__init__("{0}{1}".format(fedfind.const.HTTPS, path), **kwargs)

+         super(Pungi4Mirror, self).__init__("{}{}".format(fedfind.const.HTTPS, path), **kwargs)

  

      def __repr__(self):

-         return "{0}(path='{1}')".format(self.__class__, self._basepath)

+         return "{}(path='{}')".format(self.__class__, self._basepath)

  

      def __str__(self):

-         return "{0} {1}".format(self.__class__.__name__, self._basepath)

+         return "{} {}".format(self.__class__.__name__, self._basepath)

  

      @property

      def _checkloc(self):
@@ -1968,7 +1968,7 @@ 

          # property if we can't find a real one. We store it on the

          # instance so methods can check if we have a real or fake one

          # by doing 'self.cid == self._fakecid".

-         self._fakecid = "Fedora-{0}-19700101.0".format(self.release)

+         self._fakecid = "Fedora-{}-19700101.0".format(self.release)

  

      @abc.abstractproperty

      def _basepath(self):
@@ -2084,7 +2084,7 @@ 

              return self._exists

          url = self.https_url_generic.replace(fedfind.const.HTTPS, fedfind.const.HTTPS_DL)

          if not url:

-             url = '{0}/{1}'.format(fedfind.const.HTTPS_DL, self._basepath)

+             url = '{}/{}'.format(fedfind.const.HTTPS_DL, self._basepath)

          logger.debug("exists: checking URL %s", url)

          if fedfind.helpers.url_exists(url):

              self._exists = True
@@ -2105,9 +2105,9 @@ 

          Used for constructing image paths, etc.

          """

          if self._prefurl == "direct":

-             return "{0}/{1}".format(fedfind.const.HTTPS_DL, self._basepath)

+             return "{}/{}".format(fedfind.const.HTTPS_DL, self._basepath)

          else:

-             return "{0}/{1}".format(fedfind.const.HTTPS, self._basepath)

+             return "{}/{}".format(fedfind.const.HTTPS, self._basepath)

  

      @property

      def alt_location(self):
@@ -2115,9 +2115,9 @@ 

          Used for constructing image paths, etc.

          """

          if self._prefurl == "direct":

-             return "{0}/{1}".format(fedfind.const.HTTPS_DL, self._altbasepath)

+             return "{}/{}".format(fedfind.const.HTTPS_DL, self._altbasepath)

          else:

-             return "{0}/{1}".format(fedfind.const.HTTPS, self._altbasepath)

+             return "{}/{}".format(fedfind.const.HTTPS, self._altbasepath)

  

      @property

      def https_url_generic(self):
@@ -2129,11 +2129,11 @@ 

          if self._relnum < 7:

              return self.location

          elif self._relnum < 21:

-             return '{0}/Fedora'.format(self.location)

+             return '{}/Fedora'.format(self.location)

          elif self._relnum <= 23:

-             return '{0}/Server'.format(self.location)

+             return '{}/Server'.format(self.location)

          else:

-             return '{0}/Everything'.format(self.location)

+             return '{}/Everything'.format(self.location)

  

      @property

      def metadata(self):
@@ -2163,7 +2163,7 @@ 

              # We can try to get the real metadata from PDC and just

              # tweak it a bit.

              try:

-                 origmd = fedfind.helpers.pdc_query('compose-images/{0}'.format(self.cid))

+                 origmd = fedfind.helpers.pdc_query('compose-images/{}'.format(self.cid))

                  # we should also be able to retrieve the original

                  # composeinfo dict, but I can't find that at all...

              except ValueError:
@@ -2320,7 +2320,7 @@ 

              relname = '_'.join((self.release, self.milestone))

          else:

              relname = self.release

-         exp = re.compile(r'-{0}-(\d+\.\d+)\.'.format(relname))

+         exp = re.compile(r'-{}-(\d+\.\d+)\.'.format(relname))

          for (_, path) in self.all_paths:

              fname = path.split('/')[-1]

              match = exp.search(fname)
@@ -2385,11 +2385,11 @@ 

  

      @property

      def _basepath(self):

-         return 'fedora/linux/releases/test/{0}_{1}'.format(self.release, self.milestone)

+         return 'fedora/linux/releases/test/{}_{}'.format(self.release, self.milestone)

  

      @property

      def _altbasepath(self):

-         return 'alt/releases/test/{0}_{1}'.format(self.release, self.milestone)

+         return 'alt/releases/test/{}_{}'.format(self.release, self.milestone)

  

  ## STABLE RELEASE CLASSES ##

  
@@ -2411,11 +2411,11 @@ 

  

      @property

      def _basepath(self):

-         return 'fedora/linux/releases/{0}'.format(self.release)

+         return 'fedora/linux/releases/{}'.format(self.release)

  

      @property

      def _altbasepath(self):

-         return 'alt/releases/{0}'.format(self.release)

+         return 'alt/releases/{}'.format(self.release)

  

  

  class ArchiveRelease(MirrorRelease):
@@ -2433,12 +2433,12 @@ 

  

      @property

      def _basepath(self):

-         return 'archive/fedora/linux/releases/{0}'.format(self.release)

+         return 'archive/fedora/linux/releases/{}'.format(self.release)

  

      @property

      def _altbasepath(self):

          if self._relnum > 14:

-             return 'alt/releases/{0}'.format(self.release)

+             return 'alt/releases/{}'.format(self.release)

          else:

              # there were no 'alt' bits prior to F15

              return None
@@ -2459,7 +2459,7 @@ 

  

      @property

      def _basepath(self):

-         return 'archive/fedora/linux/core/{0}'.format(self.release)

+         return 'archive/fedora/linux/core/{}'.format(self.release)

  

      @property

      def _altbasepath(self):
@@ -2500,20 +2500,20 @@ 

                  "Could not determine release and compose for current respin release!")

          if release and release != gotrelease:

              raise fedfind.exceptions.DiscoveryError(

-                 "RespinRelease: discovered release {0} does not match "

-                 "requested release {1}!".format(gotrelease, release))

+                 "RespinRelease: discovered release {} does not match "

+                 "requested release {}!".format(gotrelease, release))

          if compose and compose != gotcompose:

              raise fedfind.exceptions.DiscoveryError(

-                 "RespinRelease: discovered compose {0} does not match "

-                 "requested compose {1}!".format(gotcompose, compose))

+                 "RespinRelease: discovered compose {} does not match "

+                 "requested compose {}!".format(gotcompose, compose))

          super(RespinRelease, self).__init__(gotrelease, milestone, gotcompose)

          # if we got this far, we already know we exist

          self._exists = True

          # custom fake CID for these releases

-         self._fakecid = "FedoraRespin-{0}-updates-{1}.0".format(self.release, self.compose)

+         self._fakecid = "FedoraRespin-{}-updates-{}.0".format(self.release, self.compose)

  

      def __repr__(self):

-         return "{0}()".format(self.__class__)

+         return "{}()".format(self.__class__)

  

      @property

      def _basepath(self):

file removed
-4
@@ -1,4 +0,0 @@ 

- cached-property == 1.3.1

- productmd

- setuptools == 0.6.rc10

- six == 1.7.3

file removed
-2
@@ -1,2 +0,0 @@ 

- pytest==2.3.5

- mock==1.0.1

file modified
+22 -89
@@ -98,54 +98,22 @@ 

      """

      root = os.path.join(os.path.dirname(os.path.realpath(__file__)),

                          'data', 'http')

-     # sigh, this is disappointingly messy, but we want to handle doing

-     # this with py2 or py3, and the module name differs.

-     argn = 0

-     possargs = [

-         ('python3', "-m", "http.server", "5001"),

-         ('python2', "-m", "SimpleHTTPServer", "5001"),

-         ('python', "-m", "http.server", "5001"),

-         ('python', "-m", "SimpleHTTPServer", "5001"),

-     ]

-     while True:

-         try:

-             proc = subprocess.Popen(possargs[argn], cwd=root)

-             break

-         except OSError:

-             argn += 1

-             if argn >= len(possargs):

-                 raise EnvironmentError("Could not find any Python interpreter "

-                                        "for test HTTP server")

+     args = ("python3", "-m", "http.server", "5001")

+     proc = subprocess.Popen(args, cwd=root)

      # block until the server is actually running

      resp = None

      while not resp:

          try:

              resp = urlopen('http://localhost:5001/pub')

          except (ValueError, URLError, HTTPError):

-             # python2 -m http.server doesn't work, but exits 0. wtf, python2.

-             if proc.poll() is not None:

-                 # this means the proc exited, which probably means the

-                 # module name was wrong or something; try next

-                 argn += 1

-                 if argn < len(possargs):

-                     proc = subprocess.Popen(possargs[argn], cwd=root)

-                 else:

-                     raise EnvironmentError("Could not run test HTTP server with any "

-                                            "available Python interpreter")

              time.sleep(0.1)

      # Redefine the HTTPS_DL and HTTPS constants to point to the fake

      fedfind.const.HTTPS_DL = 'http://localhost:5001/pub'

      fedfind.const.HTTPS = 'http://localhost:5001/pub'

+     yield

  

-     def fin():

-         """Teardown: kill the server. We don't use the 'yield fixture'

-         feature here because we want these tests to run on EL 6, and

-         the steam-powered ancient pytest in EL 6 doesn't have it.

-         """

-         proc.kill()

-     request.addfinalizer(fin)

- 

-     return None

+     # teardown

+     proc.kill()

  

  @pytest.fixture(scope="function")

  def clean_home(request):
@@ -160,22 +128,15 @@ 

          shutil.rmtree(home)

      cachedir = os.path.join(home, '.cache', 'fedfind')

      os.makedirs(cachedir)

-     patcher = mock.patch('os.path.expanduser', return_value=home, autospec=True)

-     patcher.start()

-     origcache = fedfind.helpers.CACHEDIR

-     fedfind.helpers.CACHEDIR = cachedir

- 

-     def fin():

-         """Teardown: stop the patcher and wipe the directory. As per

-         http, we can't use the yield syntax here because EL 6.

-         """

-         patcher.stop()

-         fedfind.helpers.CACHEDIR = origcache

-         if os.path.exists(home):

-             shutil.rmtree(home)

-     request.addfinalizer(fin)

+     with mock.patch('os.path.expanduser', return_value=home, autospec=True):

+         origcache = fedfind.helpers.CACHEDIR

+         fedfind.helpers.CACHEDIR = cachedir

+         yield home

  

-     return home

+     # teardown stuff

+     fedfind.helpers.CACHEDIR = origcache

+     if os.path.exists(home):

+         shutil.rmtree(home)

  

  def fake_pdc_query(path, params=None):

      """A fake pdc_query that doesn't really hit PDC, it just returns
@@ -210,40 +171,22 @@ 

      match = compimgs.match(path)

      if match:

          fname = os.path.join(os.path.dirname(os.path.realpath(__file__)),

-                              'data', 'pdc-compimages-{0}.json'.format(match.group(1)))

+                              'data', 'pdc-compimages-{}.json'.format(match.group(1)))

          with open(fname, 'r') as datafh:

              return json.loads(datafh.read())

  

  @pytest.fixture(scope="function")

  def pdc(request):

      """Mock fedfind.helpers.pdc_query with fake_pdc_query."""

-     patcher = mock.patch('fedfind.helpers.pdc_query', fake_pdc_query)

-     patcher.start()

- 

-     def fin():

-         """Teardown: stop the patcher and wipe the directory. As per

-         http, we can't use the yield syntax here because EL 6.

-         """

-         patcher.stop()

-     request.addfinalizer(fin)

- 

-     return None

+     with mock.patch('fedfind.helpers.pdc_query', fake_pdc_query):

+         yield

  

  @pytest.fixture(scope="function")

  def collections(request):

      """Mock fedfind.helpers._get_collections to return test data."""

-     patcher = mock.patch('fedfind.helpers._get_collections', return_value=COLLECTIONS_JSON,

-                          autospec=True)

-     patcher.start()

- 

-     def fin():

-         """Teardown: stop the patcher and wipe the directory. As per

-         http, we can't use the yield syntax here because EL 6.

-         """

-         patcher.stop()

-     request.addfinalizer(fin)

- 

-     return None

+     with mock.patch('fedfind.helpers._get_collections', return_value=COLLECTIONS_JSON,

+                     autospec=True):

+         yield

  

  @pytest.fixture(scope="function")

  def json_collections(request):
@@ -251,18 +194,8 @@ 

      data (wrapped appropriately). Returns the mock so tests can check

      its call count, and the test data so they can verify it.

      """

-     patcher = mock.patch(

-         'fedfind.helpers.download_json', return_value={'collections': COLLECTIONS_JSON},

-         autospec=True)

-     mocked = patcher.start()

- 

-     def fin():

-         """Teardown: stop the patcher and wipe the directory. As per

-         http, we can't use the yield syntax here because EL 6.

-         """

-         patcher.stop()

-     request.addfinalizer(fin)

- 

-     return (mocked, COLLECTIONS_JSON)

+     with mock.patch('fedfind.helpers.download_json',

+                     return_value={'collections': COLLECTIONS_JSON}, autospec=True) as mocked:

+         yield (mocked, COLLECTIONS_JSON)

  

  # vim: set textwidth=100 ts=8 et sw=4:

file modified
+2 -2
@@ -466,7 +466,7 @@ 

          def check_file(flist, touch=False):

              """Inner function for doing the check (run multiple times)"""

              origfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'http',

-                                     'pub', flist, 'imagelist-{0}'.format(flist))

+                                     'pub', flist, 'imagelist-{}'.format(flist))

              if touch:

                  os.utime(origfile, None)

              gotcksum = hashlib.md5()
@@ -474,7 +474,7 @@ 

              record = {}

              with fedfind.helpers._get_filelist(flist=flist, record=record) as testfh:

                  assert testfh.name == os.path.join(clean_home, '.cache', 'fedfind',

-                                                    'imagelist-{0}'.format(flist))

+                                                    'imagelist-{}'.format(flist))

                  for line in testfh:

                      gotcksum.update(line.encode('utf-8'))

              with codecs.open(origfile, encoding='utf-8') as origfh:

file modified
+3 -7
@@ -217,7 +217,7 @@ 

          """Returns the appropriate chunk of HTML (see above) if the

          correct URL was given.

          """

-         arcbase = '{0}/archive/fedora/linux/'.format(fedfind.const.HTTPS)

+         arcbase = '{}/archive/fedora/linux/'.format(fedfind.const.HTTPS)

          branchbase = 'https://kojipkgs.fedoraproject.org/compose/branched/Fedora-24-20160321.n.0/'

          modbase = 'https://kojipkgs.fedoraproject.org/compose/Fedora-Modular-27-20171115.n.1/'

          mapping = {
@@ -239,7 +239,7 @@ 

          if self.url in mapping:

              return six.b(mapping[self.url])

          else:

-             raise ValueError("URL {0} not expected!".format(self.url))

+             raise ValueError("URL {} not expected!".format(self.url))

  

  def urlopen_fake_package(url):

      """Stub for urlopen_retries which returns FakeResponsePackages."""
@@ -1057,6 +1057,7 @@ 

                  # old-style line, size should not be in dict at all

                  assert 'size' not in img

  

+     @mock.patch('fedfind.release.CurrentRelease.exists', True)

      def test_all_stable(self, http, pdc):

          """Test that we get the expected image dicts for all stable

          releases, using the test HTTP server and home directory and
@@ -1073,10 +1074,6 @@ 

          # backing data for this test to include a new release, is if

          # any sneaky new subvariants showed up...

          subvs = [subv.name for subv in fedfind.const.SUBVARIANTS]

-         # for some bizarre reason, if we do this as a decorator like

-         # normal, the test blows up on Python 2.6

-         patcher = mock.patch('fedfind.release.CurrentRelease.exists', True)

-         patcher.start()

          for relnum in expected:

              rel = fedfind.release.get_release(relnum)

              imgs = sorted(rel.all_images, key=lambda x: x['path'])
@@ -1089,7 +1086,6 @@ 

              # check_expected bails

              rel._exists = True

              assert not rel.check_expected()

-         patcher.stop()

  

      def test_images_respinrelease(self, http):

          """Test that we get approximately the expected image dicts for

file modified
+10 -14
@@ -1,18 +1,14 @@ 

  [tox]

- envlist = py26,py27,py34,py35,py36,py37

- skip_missing_interpreters=true

+ envlist = py27,py36,py37,py38,py39

+ skip_missing_interpreters = true

  [testenv]

- deps=py27,py34,py35,py36,py37: -r{toxinidir}/install.requires

-      py26: -r{toxinidir}/install.requires.py26

-      py27,py34,py35,py36,py37: -r{toxinidir}/tests.requires

-      py26: -r{toxinidir}/tests.requires.py26

-      py27,py34,py35,py36,py37: -r{toxinidir}/tox.requires

-      py26: -r{toxinidir}/tox.requires.py26

- commands=py27,py34,py35,py36,py37: py.test --cov-report term-missing --cov-report xml --cov fedfind

-          py26: py.test

-          py27,py34,py35,py36,py37: diff-cover coverage.xml --fail-under=90

-          # pylint breaks on functools imports in python 3.6+

-          # https://github.com/PyCQA/astroid/issues/362

-          py27,py34,py35: diff-quality --violations=pylint --fail-under=90

+ deps =

+     -r{toxinidir}/install.requires

+     -r{toxinidir}/tests.requires

+     -r{toxinidir}/tox.requires

+ commands =

+     py.test --cov-report term-missing --cov-report xml --cov fedfind

+     diff-cover coverage.xml --fail-under=90

+     diff-quality --violations=pylint --fail-under=90

  setenv =

      PYTHONPATH = {toxinidir}

file removed
-1
@@ -1,1 +0,0 @@ 

- pylint

RHEL 6 doesn't go EOL till November, but the tests mysteriously
fail on EPEL 6 since 4.3.0, tox in current Fedoras can't run a
py26 environment any more, and my quotient of f**s to give is
running low...so we officially don't support py26 any more as of
now. Next on the chopping block: py27.

This drops py26 (and all the special handling for it) from the
tox configuration, and updates some code to use syntax that only
works in 2.7 or later, and drops various annoying workarounds
that were only needed for RHEL 6 / Python 2.6 compatibility in
other ways.

Signed-off-by: Adam Williamson awilliam@redhat.com

I'm not fixing test coverage for this :P the tests do pass. Merging.

Pull-Request has been merged by adamwill

4 years ago