From 92ecb6f95914cb8cfdbbd5a974e67d6be5ad20f8 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:40:47 -0300 Subject: [PATCH] test --- tools/get.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/tools/get.py b/tools/get.py index 68b92e05da7..baf31ebd876 100755 --- a/tools/get.py +++ b/tools/get.py @@ -107,12 +107,14 @@ def verify_files(filename, destination, rename_to): for i, zipped_file in enumerate(archive.namelist(), 1): local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1)) if not os.path.exists(local_path): - print(f"\nMissing {zipped_file} on location: {extracted_dir_path}") - print(f"Verification failed; aborted in {format_time(time.time() - t1)}") + if verbose: + print(f"\nMissing {zipped_file} on location: {extracted_dir_path}") + print(f"Verification failed; aborted in {format_time(time.time() - t1)}") return False print_verification_progress(total_files, i, t1) except zipfile.BadZipFile: - print(f"Verification failed; aborted in {format_time(time.time() - t1)}") + if verbose: + print(f"Verification failed; aborted in {format_time(time.time() - t1)}") return False elif filename.endswith(".tar.gz"): try: @@ -122,12 +124,14 @@ def verify_files(filename, destination, rename_to): for i, zipped_file in enumerate(archive.getnames(), 1): local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1)) if not os.path.exists(local_path): - print(f"\nMissing {zipped_file} on location: {extracted_dir_path}") - print(f"Verification failed; aborted in {format_time(time.time() - t1)}") + if verbose: + print(f"\nMissing {zipped_file} on location: {extracted_dir_path}") + print(f"Verification failed; aborted in {format_time(time.time() - t1)}") return False print_verification_progress(total_files, i, t1) except tarfile.ReadError: - print(f"Verification failed; aborted in {format_time(time.time() - t1)}") + if verbose: + print(f"Verification failed; aborted in {format_time(time.time() - t1)}") return False elif filename.endswith(".tar.xz"): try: @@ -137,12 +141,14 @@ def verify_files(filename, destination, rename_to): for i, zipped_file in enumerate(archive.getnames(), 1): local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1)) if not os.path.exists(local_path): - print(f"\nMissing {zipped_file} on location: {extracted_dir_path}") - print(f"Verification failed; aborted in {format_time(time.time() - t1)}") + if verbose: + print(f"\nMissing {zipped_file} on location: {extracted_dir_path}") + print(f"Verification failed; aborted in {format_time(time.time() - t1)}") return False print_verification_progress(total_files, i, t1) except tarfile.ReadError: - print(f"Verification failed; aborted in {format_time(time.time() - t1)}") + if verbose: + print(f"Verification failed; aborted in {format_time(time.time() - t1)}") return False else: raise NotImplementedError("Unsupported archive type") @@ -231,7 +237,12 @@ def unpack(filename, destination, force_extract): # noqa: C901 shutil.rmtree(rename_to) shutil.move(dirname, rename_to) - return True + if verify_files(filename, destination, rename_to): + print(" Files extracted successfully.") + return True + else: + print(" Failed to extract files.") + return False def download_file_with_progress(url, filename, start_time): @@ -291,6 +302,7 @@ def get_tool(tool, force_download, force_extract): local_path = dist_dir + archive_name url = tool["url"] start_time = time.time() + print("") if not os.path.isfile(local_path) or force_download: if verbose: print("Downloading '" + archive_name + "' to '" + local_path + "'") @@ -421,6 +433,9 @@ def identify_platform(): current_dir + "/../package/package_esp32_index.template.json", identified_platform ) mkdir_p(dist_dir) + + print("\nDownloading and extracting tools...") + for tool in tools_to_download: if is_test: print("Would install: {0}".format(tool["archiveFileName"])) @@ -432,4 +447,4 @@ def identify_platform(): print(f"Tool {tool['archiveFileName']} was corrupted, but re-downloading did not help!\n") sys.exit(1) - print("Platform Tools Installed") + print("\nPlatform Tools Installed")