Skip to content

Commit b6f0667

Browse files
committed
add unpacking bar
1 parent 1e1916e commit b6f0667

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

archive.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
import zipfile
3232
import pkgsdb
3333
from cmds.cmd_package.cmd_package_utils import is_windows, remove_folder
34-
34+
from tqdm import tqdm
3535

3636
def unpack(archive_filename, bsp_package_path, package_info, package_name):
37+
print('unpacking ' + package_name + ' ...')
3738
if ".tar.bz2" in archive_filename:
3839
arch = tarfile.open(archive_filename, "r:bz2")
39-
for tarinfo in arch:
40+
for tarinfo in tqdm(arch):
4041
arch.extract(tarinfo, bsp_package_path)
4142
a = tarinfo.name
4243
if not os.path.isdir(os.path.join(bsp_package_path, a)):
@@ -51,7 +52,7 @@ def unpack(archive_filename, bsp_package_path, package_info, package_name):
5152

5253
if ".tar.gz" in archive_filename:
5354
arch = tarfile.open(archive_filename, "r:gz")
54-
for tarinfo in arch:
55+
for tarinfo in tqdm(arch):
5556
arch.extract(tarinfo, bsp_package_path)
5657
a = tarinfo.name
5758
if not os.path.isdir(os.path.join(bsp_package_path, a)):
@@ -89,7 +90,7 @@ def handle_zip_package(archive_filename, bsp_package_path, package_name, package
8990
package_folder_name = ""
9091
package_name_with_version = ""
9192
arch = zipfile.ZipFile(archive_filename, "r")
92-
for item in arch.namelist():
93+
for item in tqdm(arch.namelist()):
9394
arch.extract(item, package_temp_path)
9495
if not os.path.isdir(os.path.join(package_temp_path, item)):
9596
# Gets the folder name and changed folder name only once

package.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def download(self, ver, path, url_from_srv):
179179
os.remove(path)
180180
else:
181181
if archive.package_integrity_test(path):
182-
# print "The file is rigit."
183182
return True
184183
else:
185184
os.remove(path)
@@ -191,7 +190,7 @@ def download(self, ver, path, url_from_srv):
191190
'Accept': '*/*',
192191
'User-Agent': 'curl/7.54.0'}
193192

194-
print('Start to download package : %s ' % filename.encode("utf-8"))
193+
print('downloading ' + filename + ' ...')
195194

196195
while True:
197196
try:
@@ -209,8 +208,6 @@ def download(self, ver, path, url_from_srv):
209208

210209
if archive.package_integrity_test(path): # make sure the file is right
211210
ret = True
212-
print("\rDownloded %d KB " % flush_count)
213-
print('Start to unpack. Please wait...')
214211
break
215212
else:
216213
if os.path.isfile(path):

0 commit comments

Comments
 (0)