def check_if_dependency_is_valid(self): if os.path.exists(CRYPTO_LIBRARY_PATH): if md5sum(CRYPTO_LIBRARY_PATH) == CYPTO_MD5SUM: return True else: os.remove(CRYPTO_LIBRARY_PATH) return False return False
def _save_dependency_file(self, fetcher_task): if fetcher_task.reply() is not None: # Write response to tmp file tmp_file = tempfile.mktemp() out_file = QFile(tmp_file) out_file.open(QIODevice.WriteOnly) out_file.write(fetcher_task.reply().readAll()) out_file.close() if not os.path.exists(DEPENDENCIES_BASE_PATH): os.makedirs(DEPENDENCIES_BASE_PATH) if md5sum(tmp_file) == DICT_JAVA_MD5SUM[KEY_JAVA_OS_VERSION]: try: tar = tarfile.open(tmp_file) tar.extractall(DEPENDENCIES_BASE_PATH) tar.close() except tarfile.ReadError as e: self.logger.warning_msg( __name__, QCoreApplication.translate( "JavaDependency", "There was an error with the download. The downloaded file is invalid." )) except PermissionError as e: self.logger.warning_msg( __name__, QCoreApplication.translate( "JavaDependency", "Java couldn't be installed. Check if it is possible to write into this folder: <a href='file:///{path}'>{path}</a>" ).format(path=normalize_local_url( os.path.join( DEPENDENCIES_BASE_PATH, DICT_JAVA_DIR_NAME[KEY_JAVA_OS_VERSION])))) else: self.logger.warning_msg( __name__, QCoreApplication.translate( "JavaDependency", "There was an error with the download. The downloaded file is invalid." )) try: os.remove(tmp_file) except: pass self._downloading = False