import os.path import shutil from etl.common.PathsAndTable import PathsAndTable from service.trans_conf_service import update_archive_success from utils.log.trans_log import trans_print class ArchiveFile(object): def __init__(self, pathsAndTable: PathsAndTable, exec_id): self.pathsAndTable = pathsAndTable self.exec_id = exec_id def run(self): """ 归档文件 """ if os.path.exists(self.pathsAndTable.get_tmp_formal_path()): shutil.make_archive(self.pathsAndTable.get_archive_path(), 'zip', self.pathsAndTable.get_tmp_formal_path()) update_archive_success(self.exec_id, f"{self.pathsAndTable.get_archive_path()}.zip") trans_print(f"文件夹已归档为 {self.pathsAndTable.get_archive_path()}.zip") else: trans_print(f"文件夹 {self.pathsAndTable.get_tmp_formal_path()} 不存在")