提交 14e8a401 编写于 作者: W wuzewu

Fix test script bug

上级 9b08fe89
...@@ -20,6 +20,7 @@ import sys ...@@ -20,6 +20,7 @@ import sys
import tarfile import tarfile
import zipfile import zipfile
import platform import platform
import functools
lasttime = time.time() lasttime = time.time()
FLUSH_INTERVAL = 0.1 FLUSH_INTERVAL = 0.1
...@@ -78,8 +79,10 @@ def _uncompress_file(filepath, extrapath, delete_file, print_progress): ...@@ -78,8 +79,10 @@ def _uncompress_file(filepath, extrapath, delete_file, print_progress):
if filepath.endswith("zip"): if filepath.endswith("zip"):
handler = _uncompress_file_zip handler = _uncompress_file_zip
else: elif filepath.endswith("tgz"):
handler = _uncompress_file_tar handler = _uncompress_file_tar
else:
handler = functools.partial(_uncompress_file_tar, mode="r")
for total_num, index in handler(filepath, extrapath): for total_num, index in handler(filepath, extrapath):
if print_progress: if print_progress:
...@@ -104,8 +107,8 @@ def _uncompress_file_zip(filepath, extrapath): ...@@ -104,8 +107,8 @@ def _uncompress_file_zip(filepath, extrapath):
yield total_num, index yield total_num, index
def _uncompress_file_tar(filepath, extrapath): def _uncompress_file_tar(filepath, extrapath, mode="r:gz"):
files = tarfile.open(filepath, "r:gz") files = tarfile.open(filepath, mode)
filelist = files.getnames() filelist = files.getnames()
total_num = len(filelist) total_num = len(filelist)
for index, file in enumerate(filelist): for index, file in enumerate(filelist):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册