Esempio n. 1
0
 def _verified_download(self, firmware: Firmware, hash_firmware: str,
                        max_attempts: int) -> bool:
     """
     Downloads the given Firmware and checks if the download was correct and if the hash is matching
     :param firmware:
     :param hash_firmware:
     :param max_attempts: max number of attemps to download a firmware
     :return: bool
     """
     valid_download = False
     count = 0
     while (not valid_download) & (count < max_attempts):
         valid_download = self._download_file(firmware.url, firmware.file,
                                              firmware.release_model)
         if valid_download:
             valid_download = firmware.check_hash(hash_firmware)
         count += 1
     if count >= max_attempts:
         Logger().debug(
             "[-] The Firmware(" + firmware.name +
             ") couldn't be downloaded", 3)
         return False
     else:
         Logger().debug(
             "[+] The Firmware(" + firmware.name +
             ") was successfully downloaded", 3)
         return True
Esempio n. 2
0
 def _verified_download(self, firmware: Firmware, hash_firmware: str, max_attempts: int) -> bool:
     """
     Downloads the given Firmware and checks if the download was correct and if the hash is matching
     :param firmware:
     :param hash_firmware:
     :param max_attempts: max number of attemps to download a firmware
     :return: bool
     """
     valid_download = False
     count = 0
     while (not valid_download) & (count < max_attempts):
         valid_download = self._download_file(firmware.url, firmware.file, firmware.release_model)
         if valid_download:
             valid_download = firmware.check_hash(hash_firmware)
         count += 1
     if count >= max_attempts:
         Logger().debug("[-] The Firmware(" + firmware.name + ") couldn't be downloaded", 3)
         return False
     else:
         Logger().debug("[+] The Firmware(" + firmware.name + ") was successfully downloaded", 3)
         return True
Esempio n. 3
0
    def _verified_download(self, firmware: Firmware, hash_firmware: str, max_attempts: int) -> bool:
        """
        Downloads the given Firmware and checks if the download was correct and if the hash is matching.

        :param firmware: Firmware-Obj
        :param hash_firmware: Expected hash
        :param max_attempts: Maximal number of attempts to download a Firmware
        :return: 'True' if the Firmware could be downloaded and the hash is correct
        """
        valid_download = False
        count = 0
        while (not valid_download) & (count < max_attempts):
            valid_download = self._download_file(firmware.url, firmware.file, firmware.release_model)
            if valid_download:
                valid_download = firmware.check_hash(hash_firmware)
            count += 1
        if count >= max_attempts:
            logging.warning("%s[-] The Firmware(" + firmware.name + ") couldn't be downloaded",
                            LoggerSetup.get_log_deep(3))
            return False
        else:
            logging.info("%s[+] The Firmware(" + firmware.name + ") was successfully downloaded",
                         LoggerSetup.get_log_deep(3))
            return True