def check_iso(url, destination, hash): """ Verifies if ISO that can be find on url is on destination with right hash. This function will verify the SHA1 hash of the ISO image. If the file turns out to be missing or corrupted, let the user know we can download it. @param url: URL where the ISO file can be found. @param destination: Directory in local disk where we'd like the iso to be. @param hash: SHA1 hash for the ISO image. """ file_ok = False if not destination: os.makedirs(destination) iso_path = os.path.join(destination, os.path.basename(url)) if not os.path.isfile(iso_path): logging.warning("File %s not found", iso_path) logging.warning("Expected SHA1 sum: %s", hash) answer = utils.ask("Would you like to download it from %s?" % url) if answer == 'y': try: utils.unmap_url_cache(destination, url, hash, method="sha1") file_ok = True except EnvironmentError, e: logging.error(e) else: logging.warning("Missing file %s", iso_path) logging.warning( "Please download it or put an exsiting copy on the " "appropriate location") return
def check_iso(url, destination, hash): """ Verifies if ISO that can be find on url is on destination with right hash. This function will verify the SHA1 hash of the ISO image. If the file turns out to be missing or corrupted, let the user know we can download it. @param url: URL where the ISO file can be found. @param destination: Directory in local disk where we'd like the iso to be. @param hash: SHA1 hash for the ISO image. """ file_ok = False if not destination: os.makedirs(destination) iso_path = os.path.join(destination, os.path.basename(url)) if not os.path.isfile(iso_path): logging.warning("File %s not found", iso_path) logging.warning("Expected SHA1 sum: %s", hash) answer = utils.ask("Would you like to download it from %s?" % url) if answer == 'y': try: utils.unmap_url_cache(destination, url, hash, method="sha1") file_ok = True except EnvironmentError, e: logging.error(e) else: logging.warning("Missing file %s", iso_path) logging.warning("Please download it or put an exsiting copy on the " "appropriate location") return
if answer == 'y': try: utils.unmap_url_cache(destination, url, hash, method="sha1") file_ok = True except EnvironmentError, e: logging.error(e) else: logging.warning("Missing file %s", iso_path) logging.warning( "Please download it or put an exsiting copy on the " "appropriate location") return else: logging.info("Found %s", iso_path) logging.info("Expected SHA1 sum: %s", hash) answer = utils.ask( "Would you like to check %s? It might take a while" % iso_path) if answer == 'y': try: utils.unmap_url_cache(destination, url, hash, method="sha1") file_ok = True except EnvironmentError, e: logging.error(e) else: logging.info("File %s present, but chose to not verify it", iso_path) return if file_ok: logging.info("%s present, with proper checksum", iso_path)
answer = utils.ask("Would you like to download it from %s?" % url) if answer == 'y': try: utils.unmap_url_cache(destination, url, hash, method="sha1") file_ok = True except EnvironmentError, e: logging.error(e) else: logging.warning("Missing file %s", iso_path) logging.warning("Please download it or put an exsiting copy on the " "appropriate location") return else: logging.info("Found %s", iso_path) logging.info("Expected SHA1 sum: %s", hash) answer = utils.ask("Would you like to check %s? It might take a while" % iso_path) if answer == 'y': try: utils.unmap_url_cache(destination, url, hash, method="sha1") file_ok = True except EnvironmentError, e: logging.error(e) else: logging.info("File %s present, but chose to not verify it", iso_path) return if file_ok: logging.info("%s present, with proper checksum", iso_path)