(self)
return sorted(mirrors, key=lambda c: c.sort_key, reverse=True)
A list of :class:`CandidateMirror` objects (ordered from best to worst)
A list of :class:`CandidateMirror` objects (ordered from best to worst)
A list of : class : CandidateMirror objects ( ordered from best to worst )
def available_mirrors(self):
        """A list of :class:`CandidateMirror` objects (ordered from best to worst)"""
        mirrors = set()
        if self.release_is_eol:
            logger.warning("Skipping mirror discovery because %s is EOL.", self.release)
        else:
            if self.read_custom_mirror_file:
                mirrors.update(self.read_custom_mirror_file)
                logger.info("Custom mirrors added from file:")
                for mirror in mirrors:
                    logger.info(mirror.mirror_url)
            logger.info("Adding BASE_URL mirror:")
            if self.distributor_id == 'debian':  # For Debian, base_url typically is not in MIRRORS_URL,
                # add it explicitly
                base_url_prefix = self.backend.BASE_URL.split('/dists/codename-updates/Release')[0]
                mirrors.add(CandidateMirror(mirror_url=base_url_prefix, updater=self))
            elif self.distributor_id == 'ubuntu':  # For Ubuntu, base_url is not in MIRRORS_URL for
                # some countries e.g. US (found it in Travis CI), add it explicitly
                base_url_prefix = self.backend.BASE_URL.split('/dists/codename-security/Release')[0]
                mirrors.add(CandidateMirror(mirror_url=base_url_prefix, updater=self))
            elif self.distributor_id == 'linuxmint':  # For Linux Mint, base_url typically is not in MIRRORS_URL,
                # add it explicitly
                base_url_prefix = self.backend.BASE_URL.split('/dists/codename/Release')[0]
                mirrors.add(CandidateMirror(mirror_url=base_url_prefix, updater=self))
            logger.info(base_url_prefix)
            for candidate in self.backend.discover_mirrors():
                if any(fnmatch.fnmatch(candidate.mirror_url, pattern) for pattern in self.blacklist)\
                        and normalize_mirror_url(candidate.mirror_url) != base_url_prefix:
                    logger.warning("Ignoring blacklisted mirror %s.", candidate.mirror_url)
                else:
                    candidate.updater = self
                    mirrors.add(candidate)
        # We make an attempt to incorporate the system's current mirror in
        # the candidates but we don't propagate failures while doing so.
        try:
            # Gotcha: We should never include the system's current mirror in
            # the candidates when we're bootstrapping a chroot for a different
            # platform.
            # if self.distributor_id == self.context.distributor_id: # We don't need to check this since
            # 60850cc2 commint (Reimplement more robust :attr:`distribution_codename` using APT sources.list)
            # already using :attr:`context` and self.context.distributor_id has issue:
            # https://github.com/xolox/python-executor/issues/17
            mirrors.add(CandidateMirror(mirror_url=self.current_mirror, updater=self))
        except Exception as e:
            logger.warning("Failed to add current mirror to set of available mirrors! (%s)", e)
        # Sort the mirrors based on the currently available information.
        return sorted(mirrors, key=lambda c: c.sort_key, reverse=True)
def available_mirrors ( self ) : mirrors = set ( ) if self . release_is_eol : logger . warning ( "Skipping mirror discovery because %s is EOL." , self . release ) else : if self . read_custom_mirror_file : mirrors . update ( self . read_custom_mirror_file ) logger . info ( "Custom mirrors added from file:" ) for mirror in mirrors : logger . info ( mirror . mirror_url ) logger . info ( "Adding BASE_URL mirror:" ) if self . distributor_id == 'debian' : # For Debian, base_url typically is not in MIRRORS_URL, # add it explicitly base_url_prefix = self . backend . BASE_URL . split ( '/dists/codename-updates/Release' ) [ 0 ] mirrors . add ( CandidateMirror ( mirror_url = base_url_prefix , updater = self ) ) elif self . distributor_id == 'ubuntu' : # For Ubuntu, base_url is not in MIRRORS_URL for # some countries e.g. US (found it in Travis CI), add it explicitly base_url_prefix = self . backend . BASE_URL . split ( '/dists/codename-security/Release' ) [ 0 ] mirrors . add ( CandidateMirror ( mirror_url = base_url_prefix , updater = self ) ) elif self . distributor_id == 'linuxmint' : # For Linux Mint, base_url typically is not in MIRRORS_URL, # add it explicitly base_url_prefix = self . backend . BASE_URL . split ( '/dists/codename/Release' ) [ 0 ] mirrors . add ( CandidateMirror ( mirror_url = base_url_prefix , updater = self ) ) logger . info ( base_url_prefix ) for candidate in self . backend . discover_mirrors ( ) : if any ( fnmatch . fnmatch ( candidate . mirror_url , pattern ) for pattern in self . blacklist ) and normalize_mirror_url ( candidate . mirror_url ) != base_url_prefix : logger . warning ( "Ignoring blacklisted mirror %s." , candidate . mirror_url ) else : candidate . updater = self mirrors . add ( candidate ) # We make an attempt to incorporate the system's current mirror in # the candidates but we don't propagate failures while doing so. try : # Gotcha: We should never include the system's current mirror in # the candidates when we're bootstrapping a chroot for a different # platform. # if self.distributor_id == self.context.distributor_id: # We don't need to check this since # 60850cc2 commint (Reimplement more robust :attr:`distribution_codename` using APT sources.list) # already using :attr:`context` and self.context.distributor_id has issue: # https://github.com/xolox/python-executor/issues/17 mirrors . add ( CandidateMirror ( mirror_url = self . current_mirror , updater = self ) ) except Exception as e : logger . warning ( "Failed to add current mirror to set of available mirrors! (%s)" , e ) # Sort the mirrors based on the currently available information. return sorted ( mirrors , key = lambda c : c . sort_key , reverse = True )