Skip to content

Commit

Permalink
Revert "fix(get.py): Verify files after extraction and make it more r…
Browse files Browse the repository at this point in the history
…eadable"

This reverts commit cc40edb.
  • Loading branch information
lucasssvaz committed Jun 7, 2024
1 parent fbf94b2 commit 5b1a3a3
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions tools/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ 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):
if verbose:
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
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:
if verbose:
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
return False
elif filename.endswith(".tar.gz"):
try:
Expand All @@ -124,14 +122,12 @@ 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):
if verbose:
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
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:
if verbose:
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
return False
elif filename.endswith(".tar.xz"):
try:
Expand All @@ -141,14 +137,12 @@ 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):
if verbose:
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
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:
if verbose:
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
return False
else:
raise NotImplementedError("Unsupported archive type")
Expand Down Expand Up @@ -237,12 +231,7 @@ def unpack(filename, destination, force_extract): # noqa: C901
shutil.rmtree(rename_to)
shutil.move(dirname, rename_to)

if verify_files(filename, destination, rename_to):
print(" Files extracted successfully.")
return True
else:
print(" Failed to extract files.")
return False
return True


def download_file_with_progress(url, filename, start_time):
Expand Down Expand Up @@ -302,7 +291,6 @@ 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 + "'")
Expand Down Expand Up @@ -433,9 +421,6 @@ 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"]))
Expand All @@ -447,4 +432,4 @@ def identify_platform():
print(f"Tool {tool['archiveFileName']} was corrupted, but re-downloading did not help!\n")
sys.exit(1)

print("\nPlatform Tools Installed")
print("Platform Tools Installed")

0 comments on commit 5b1a3a3

Please sign in to comment.