(self)
return sorted(mirrors, key=lambda c: c.sort_key, reverse=True)
A list of :class:`CandidateMirror` objects (ordered from best to worst).

        The value of this property is computed by concurrently testing the
        mirrors in :attr:`available_mirrors` for the following details:

        - availability (:attr:`~CandidateMirror.is_available`)
        - connection speed (:attr:`~CandidateMirror.bandwidth`)
        - update status (:attr:`~CandidateMirror.is_updating`)

        The number of mirrors to test is limited to :attr:`max_mirrors` and you
        can change the number of simultaneous HTTP connections allowed by
        setting :attr:`concurrency`.
A list of :class:`CandidateMirror` objects (ordered from best to worst).
A list of : class : CandidateMirror objects ( ordered from best to worst ) .
def ranked_mirrors(self):
        """
        A list of :class:`CandidateMirror` objects (ordered from best to worst).

        The value of this property is computed by concurrently testing the
        mirrors in :attr:`available_mirrors` for the following details:

        - availability (:attr:`~CandidateMirror.is_available`)
        - connection speed (:attr:`~CandidateMirror.bandwidth`)
        - update status (:attr:`~CandidateMirror.is_updating`)

        The number of mirrors to test is limited to :attr:`max_mirrors` and you
        can change the number of simultaneous HTTP connections allowed by
        setting :attr:`concurrency`.
        """
        timer = Timer()
        # Sort the candidates based on the currently available information
        # (and transform the input argument into a list in the process).
        mirrors = sorted(self.available_mirrors, key=lambda c: c.sort_key, reverse=True)
        # Limit the number of candidates to a reasonable number?
        # NO, we don't need to now since the backends.debian can smartly get mirrors within a country.
        # Without max_mirrors limit we can fix errors within United States (Travis CI reported) where
        # where we can get 80+ mirrors. If limit applies, base_url mirror may be deleted, then error occurs.
        """
        if self.max_mirrors and len(mirrors) > self.max_mirrors:
            mirrors = mirrors[:self.max_mirrors]
        """
        # Prepare the Release.gpg URLs to fetch.
        mapping = dict((c.release_gpg_url, c) for c in mirrors)
        num_mirrors = pluralize(len(mapping), "mirror")
        logger.info("Checking %s for availability and performance ..", num_mirrors)
        # Concurrently fetch the Release.gpg files.
        with AutomaticSpinner(label="Checking mirrors"):
            for url, data, elapsed_time in fetch_concurrent(mapping.keys(), concurrency=self.concurrency):
                candidate = mapping[url]
                candidate.release_gpg_contents = data
                candidate.release_gpg_latency = elapsed_time

        logger.info("Start retrieving :attr:`base_last_updated` using is_available")
        self.base_last_updated = 0
        if self.release_is_eol:
            self.base_last_updated = int(time.time())
            logger.warning("%s is EOL, so using time.time() as :attr:`base_last_updated`: %i",
                           self.release, self.base_last_updated)
        elif mapping[self.base_url].is_available:
            logger.debug(":attr:`base_last_updated`: %i", self.base_last_updated)
            # base_url 's contents are up-to-date naturally,so set its last_updated 0
            mapping[self.base_url].last_updated = 0
        else:  # base_url not available, use time at the moment as base_last_updated.
            self.base_last_updated = int(time.time())
            logger.warning("%s is not available, so using time.time() as :attr:`base_last_updated`: %i",
                           self.base_url, self.base_last_updated)
        # Concurrently check for Archive-Update-in-Progress markers.
        update_mapping = dict((c.archive_update_in_progress_url, c) for c in mirrors if c.is_available)
        logger.info("Checking %s for Archive-Update-in-Progress marker ..",
                    pluralize(len(update_mapping), "mirror"))
        with AutomaticSpinner(label="Checking mirrors"):
            for url, data, elapsed_time in fetch_concurrent(update_mapping.keys(), concurrency=self.concurrency):
                update_mapping[url].is_updating = data is not None
        # Sanity check our results.
        mirrors = list(mapping.values())
        logger.info("Finished checking %s (took %s).", num_mirrors, timer)
        if not any(c.is_available for c in mirrors):
            raise Exception("It looks like all %s are unavailable!" % num_mirrors)
        if all(c.is_updating for c in mirrors):
            logger.warning("It looks like all %s are being updated?!", num_mirrors)
        # blacklist BASE_URL mirror if matches blacklist pattern
        if any(fnmatch.fnmatch(mapping[self.base_url].mirror_url, pattern) for pattern in self.blacklist):
            logger.warning("Ignoring blacklisted BASE_URL mirror %s.", mapping[self.base_url].mirror_url)
            mirrors.remove(mapping[self.base_url])
        return sorted(mirrors, key=lambda c: c.sort_key, reverse=True)
def ranked_mirrors ( self ) : timer = Timer ( ) # Sort the candidates based on the currently available information # (and transform the input argument into a list in the process). mirrors = sorted ( self . available_mirrors , key = lambda c : c . sort_key , reverse = True ) # Limit the number of candidates to a reasonable number? # NO, we don't need to now since the backends.debian can smartly get mirrors within a country. # Without max_mirrors limit we can fix errors within United States (Travis CI reported) where # where we can get 80+ mirrors. If limit applies, base_url mirror may be deleted, then error occurs. """
        if self.max_mirrors and len(mirrors) > self.max_mirrors:
            mirrors = mirrors[:self.max_mirrors]
        """ # Prepare the Release.gpg URLs to fetch. mapping = dict ( ( c . release_gpg_url , c ) for c in mirrors ) num_mirrors = pluralize ( len ( mapping ) , "mirror" ) logger . info ( "Checking %s for availability and performance .." , num_mirrors ) # Concurrently fetch the Release.gpg files. with AutomaticSpinner ( label = "Checking mirrors" ) : for url , data , elapsed_time in fetch_concurrent ( mapping . keys ( ) , concurrency = self . concurrency ) : candidate = mapping [ url ] candidate . release_gpg_contents = data candidate . release_gpg_latency = elapsed_time logger . info ( "Start retrieving :attr:`base_last_updated` using is_available" ) self . base_last_updated = 0 if self . release_is_eol : self . base_last_updated = int ( time . time ( ) ) logger . warning ( "%s is EOL, so using time.time() as :attr:`base_last_updated`: %i" , self . release , self . base_last_updated ) elif mapping [ self . base_url ] . is_available : logger . debug ( ":attr:`base_last_updated`: %i" , self . base_last_updated ) # base_url 's contents are up-to-date naturally,so set its last_updated 0 mapping [ self . base_url ] . last_updated = 0 else : # base_url not available, use time at the moment as base_last_updated. self . base_last_updated = int ( time . time ( ) ) logger . warning ( "%s is not available, so using time.time() as :attr:`base_last_updated`: %i" , self . base_url , self . base_last_updated ) # Concurrently check for Archive-Update-in-Progress markers. update_mapping = dict ( ( c . archive_update_in_progress_url , c ) for c in mirrors if c . is_available ) logger . info ( "Checking %s for Archive-Update-in-Progress marker .." , pluralize ( len ( update_mapping ) , "mirror" ) ) with AutomaticSpinner ( label = "Checking mirrors" ) : for url , data , elapsed_time in fetch_concurrent ( update_mapping . keys ( ) , concurrency = self . concurrency ) : update_mapping [ url ] . is_updating = data is not None # Sanity check our results. mirrors = list ( mapping . values ( ) ) logger . info ( "Finished checking %s (took %s)." , num_mirrors , timer ) if not any ( c . is_available for c in mirrors ) : raise Exception ( "It looks like all %s are unavailable!" % num_mirrors ) if all ( c . is_updating for c in mirrors ) : logger . warning ( "It looks like all %s are being updated?!" , num_mirrors ) # blacklist BASE_URL mirror if matches blacklist pattern if any ( fnmatch . fnmatch ( mapping [ self . base_url ] . mirror_url , pattern ) for pattern in self . blacklist ) : logger . warning ( "Ignoring blacklisted BASE_URL mirror %s." , mapping [ self . base_url ] . mirror_url ) mirrors . remove ( mapping [ self . base_url ] ) return sorted ( mirrors , key = lambda c : c . sort_key , reverse = True )