" ReadError('不是bzip2文件',)"
此错误,"文件无法成功打开"是非常奇怪的,因为不是一天或两天前这是工作只是今天它不是,我无法弄清楚为什么。
def main(sqldump_dict):
print 'in main'
import os
import re
count_aim = int(str(sqldump_dict["name"]).count(".gz"))
count_aim += int(str(sqldump_dict["name"]).count(".tar"))
count = 0
sqldump_dict["sql_name"] = sqldump_dict["name"]
old_tar_path = ""
old_tar_name = ""
gz_list = int(str(sqldump_dict["name"]).count(".gz"))
tar_list = int(str(sqldump_dict["name"]).count(".tar"))
while(count != count_aim):
if count > 0:
print str(os.path.join(sqldump_dict["path"] + old_tar_path))
tar = tarfile.open(str(os.path.join(sqldump_dict["path"] + old_tar_path)))
tar.extractall(path=sqldump_dict["path"] + old_tar_path.replace(old_tar_name, ""))
tar.close()
else:
tar = tarfile.open(str(os.path.join(sqldump_dict["path"] + sqldump_dict["name"])))
tar.extractall(path=sqldump_dict["path"])
tar.close()
pat = re.compile(r'([^/]*)$')
old_tar_path = str(tar.members[0].path).replace("/", "\\")
pat_find = pat.findall(str(tar.members[0].path))
old_tar_name = str(pat_find[0])
答案 0 :(得分:0)
我还收到以下错误:
ReadError('不是bzip2文件',)
这对我有用python2.7:
sudo apt-get install python-dev
sudo pip install backports.lzma