(self)
return value
:data:`True` if :attr:`release_gpg_contents` contains the expected data, :data:`False` otherwise.

        The value of this property is computed by checking whether
        :attr:`release_gpg_contents` contains the expected data.
        This may seem like a rather obscure way of
        validating a mirror, but it was specifically chosen to detect
        all sorts of ways in which mirrors can be broken:

        - Webservers with a broken configuration that return an error page for
          all URLs.

        - Mirrors whose domain name registration has expired, where the domain
          is now being squatted and returns HTTP 200 OK responses for all URLs
          (whether they "exist" or not).
:data:`True` if :attr:`release_gpg_contents` contains the expected data, :data:`False` otherwise.
: data : True if : attr : release_gpg_contents contains the expected data : data : False otherwise .
def is_available(self):
        """
        :data:`True` if :attr:`release_gpg_contents` contains the expected data, :data:`False` otherwise.

        The value of this property is computed by checking whether
        :attr:`release_gpg_contents` contains the expected data.
        This may seem like a rather obscure way of
        validating a mirror, but it was specifically chosen to detect
        all sorts of ways in which mirrors can be broken:

        - Webservers with a broken configuration that return an error page for
          all URLs.

        - Mirrors whose domain name registration has expired, where the domain
          is now being squatted and returns HTTP 200 OK responses for all URLs
          (whether they "exist" or not).
        """
        value = False
        if self.release_gpg_contents:
            value = b'Date:' in self.release_gpg_contents
            if not value:
                logger.debug("Missing data, considering mirror unavailable (%s).", self.release_gpg_url)
            else:
                # Get all data following "Date: "
                date_string_raw = self.release_gpg_contents.decode('utf-8').split("Date: ", 1)
                if len(date_string_raw) == 2:  # split succussfully using "Date: "
                    # Get only date string like "Sun, 25 Aug 2019 23:35:36 UTC", drop other data
                    date_string = date_string_raw[1].split("\n")[0]
                    if date_string.endswith("UTC"):
                        # Convert it into UNIX timestamp
                        last_updated_time = calendar.timegm(time.strptime(date_string, "%a, %d %b %Y %H:%M:%S %Z"))
                        if self.updater.base_last_updated == 0:  # First time launch this method, must be base_url
                            self.updater.base_last_updated = last_updated_time
                            logger.debug("base_last_updated: %i", self.updater.base_last_updated)
                        else:
                            # if last_updated is 0 means this mirror is up-to-date
                            self.last_updated = self.updater.base_last_updated - last_updated_time
                            logger.debug("last_updated: %i", self.last_updated)
                    else:
                        logger.debug("Not UTC? Correct me. " + date_string)
                    logger.debug("Looks good, %s is_available return True", self.release_gpg_url)
                else:  # split fails because lacking "Date: "
                    logger.debug("Missing Date, considering mirror unavailable (%s).", self.release_gpg_url)
                    value = False
            set_property(self, 'is_available', value)
        return value
def is_available ( self ) : value = False if self . release_gpg_contents : value = b'Date:' in self . release_gpg_contents if not value : logger . debug ( "Missing data, considering mirror unavailable (%s)." , self . release_gpg_url ) else : # Get all data following "Date: " date_string_raw = self . release_gpg_contents . decode ( 'utf-8' ) . split ( "Date: " , 1 ) if len ( date_string_raw ) == 2 : # split succussfully using "Date: " # Get only date string like "Sun, 25 Aug 2019 23:35:36 UTC", drop other data date_string = date_string_raw [ 1 ] . split ( "\n" ) [ 0 ] if date_string . endswith ( "UTC" ) : # Convert it into UNIX timestamp last_updated_time = calendar . timegm ( time . strptime ( date_string , "%a, %d %b %Y %H:%M:%S %Z" ) ) if self . updater . base_last_updated == 0 : # First time launch this method, must be base_url self . updater . base_last_updated = last_updated_time logger . debug ( "base_last_updated: %i" , self . updater . base_last_updated ) else : # if last_updated is 0 means this mirror is up-to-date self . last_updated = self . updater . base_last_updated - last_updated_time logger . debug ( "last_updated: %i" , self . last_updated ) else : logger . debug ( "Not UTC? Correct me. " + date_string ) logger . debug ( "Looks good, %s is_available return True" , self . release_gpg_url ) else : # split fails because lacking "Date: " logger . debug ( "Missing Date, considering mirror unavailable (%s)." , self . release_gpg_url ) value = False set_property ( self , 'is_available' , value ) return value