fix: gzipがうまく解凍できない問題を修正
This commit is contained in:
parent
359de24943
commit
2f86987696
@ -1,6 +1,7 @@
|
||||
import gzip
|
||||
import os
|
||||
import os.path as path
|
||||
import tarfile
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import boto3
|
||||
@ -134,14 +135,14 @@ class VjskReceiveBucket(S3Bucket):
|
||||
return temporary_file_path
|
||||
|
||||
def unzip_data_file(self, filename: str):
|
||||
ret = []
|
||||
with tarfile.open(filename) as tar:
|
||||
temp_dir = os.path.dirname(filename)
|
||||
tar.extractall(path=temp_dir)
|
||||
extracted_files = tar.getnames()
|
||||
for extracted_file in extracted_files:
|
||||
file = os.path.join(temp_dir, extracted_file)
|
||||
ret.append(file)
|
||||
temp_dir = os.path.dirname(filename)
|
||||
decompress_filename = os.path.basename(filename).replace('.gz', '')
|
||||
decompress_file_path = os.path.join(temp_dir, decompress_filename)
|
||||
with gzip.open(filename, 'rb') as gz:
|
||||
with open(decompress_file_path, 'wb') as decompressed_file:
|
||||
shutil.copyfileobj(gz, decompressed_file)
|
||||
|
||||
ret = [decompress_file_path]
|
||||
return ret
|
||||
|
||||
def backup_dat_file(self, target_files: list, datetime_key: str):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user