Skip to content

Commit 5b1a3a3

Browse files
committed
Revert "fix(get.py): Verify files after extraction and make it more readable"
This reverts commit cc40edb.
1 parent fbf94b2 commit 5b1a3a3

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

tools/get.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ def verify_files(filename, destination, rename_to):
107107
for i, zipped_file in enumerate(archive.namelist(), 1):
108108
local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1))
109109
if not os.path.exists(local_path):
110-
if verbose:
111-
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
112-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
110+
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
111+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
113112
return False
114113
print_verification_progress(total_files, i, t1)
115114
except zipfile.BadZipFile:
116-
if verbose:
117-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
115+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
118116
return False
119117
elif filename.endswith(".tar.gz"):
120118
try:
@@ -124,14 +122,12 @@ def verify_files(filename, destination, rename_to):
124122
for i, zipped_file in enumerate(archive.getnames(), 1):
125123
local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1))
126124
if not os.path.exists(local_path):
127-
if verbose:
128-
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
129-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
125+
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
126+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
130127
return False
131128
print_verification_progress(total_files, i, t1)
132129
except tarfile.ReadError:
133-
if verbose:
134-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
130+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
135131
return False
136132
elif filename.endswith(".tar.xz"):
137133
try:
@@ -141,14 +137,12 @@ def verify_files(filename, destination, rename_to):
141137
for i, zipped_file in enumerate(archive.getnames(), 1):
142138
local_path = os.path.join(extracted_dir_path, zipped_file.replace(first_dir, rename_to, 1))
143139
if not os.path.exists(local_path):
144-
if verbose:
145-
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
146-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
140+
print(f"\nMissing {zipped_file} on location: {extracted_dir_path}")
141+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
147142
return False
148143
print_verification_progress(total_files, i, t1)
149144
except tarfile.ReadError:
150-
if verbose:
151-
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
145+
print(f"Verification failed; aborted in {format_time(time.time() - t1)}")
152146
return False
153147
else:
154148
raise NotImplementedError("Unsupported archive type")
@@ -237,12 +231,7 @@ def unpack(filename, destination, force_extract): # noqa: C901
237231
shutil.rmtree(rename_to)
238232
shutil.move(dirname, rename_to)
239233

240-
if verify_files(filename, destination, rename_to):
241-
print(" Files extracted successfully.")
242-
return True
243-
else:
244-
print(" Failed to extract files.")
245-
return False
234+
return True
246235

247236

248237
def download_file_with_progress(url, filename, start_time):
@@ -302,7 +291,6 @@ def get_tool(tool, force_download, force_extract):
302291
local_path = dist_dir + archive_name
303292
url = tool["url"]
304293
start_time = time.time()
305-
print("")
306294
if not os.path.isfile(local_path) or force_download:
307295
if verbose:
308296
print("Downloading '" + archive_name + "' to '" + local_path + "'")
@@ -433,9 +421,6 @@ def identify_platform():
433421
current_dir + "/../package/package_esp32_index.template.json", identified_platform
434422
)
435423
mkdir_p(dist_dir)
436-
437-
print("\nDownloading and extracting tools...")
438-
439424
for tool in tools_to_download:
440425
if is_test:
441426
print("Would install: {0}".format(tool["archiveFileName"]))
@@ -447,4 +432,4 @@ def identify_platform():
447432
print(f"Tool {tool['archiveFileName']} was corrupted, but re-downloading did not help!\n")
448433
sys.exit(1)
449434

450-
print("\nPlatform Tools Installed")
435+
print("Platform Tools Installed")

0 commit comments

Comments
 (0)