|
|
@ -25,12 +25,15 @@ def start_unzip_task(): |
|
|
|
|
|
|
|
|
|
|
|
# 从数据库中获取数据 |
|
|
|
# 从数据库中获取数据 |
|
|
|
data = db_obj.get_data_by_id(folder) |
|
|
|
data = db_obj.get_data_by_id(folder) |
|
|
|
|
|
|
|
print(data) |
|
|
|
|
|
|
|
|
|
|
|
if data and all_file['handle_zip']: |
|
|
|
if data and all_file['handle_zip']: |
|
|
|
# 解压, 增加适用历史密码重试的功能 |
|
|
|
# 解压, 增加适用历史密码重试的功能 |
|
|
|
if unzip_obj.unzip(all_file['handle_zip'][0], data['unzip_pwd']): |
|
|
|
if unzip_obj.unzip(all_file['handle_zip'][0], data['unzip_pwd']): |
|
|
|
file_obj.del_all_files(all_file['zip']) |
|
|
|
file_obj.del_all_files(all_file['zip']) |
|
|
|
else: |
|
|
|
else: |
|
|
|
|
|
|
|
print('password') |
|
|
|
|
|
|
|
print(db_obj.get_available_pwd()) |
|
|
|
for pwd in db_obj.get_available_pwd(): |
|
|
|
for pwd in db_obj.get_available_pwd(): |
|
|
|
result = unzip_obj.unzip(all_file['handle_zip'][0], pwd) |
|
|
|
result = unzip_obj.unzip(all_file['handle_zip'][0], pwd) |
|
|
|
if result: |
|
|
|
if result: |
|
|
@ -56,7 +59,7 @@ def start_unzip_task(): |
|
|
|
|
|
|
|
|
|
|
|
# 检查打印结果 |
|
|
|
# 检查打印结果 |
|
|
|
if not all_file['handle_zip'] and not all_file['zip'] and not all_file['unknown']: |
|
|
|
if not all_file['handle_zip'] and not all_file['zip'] and not all_file['unknown']: |
|
|
|
db_obj.insert_pwd(data['pwd']) |
|
|
|
db_obj.insert_pwd(data['unzip_pwd']) |
|
|
|
unzip_succeed.append(folder) if folder not in unzip_succeed else '' |
|
|
|
unzip_succeed.append(folder) if folder not in unzip_succeed else '' |
|
|
|
logger.info('全部文件已解压') |
|
|
|
logger.info('全部文件已解压') |
|
|
|
return result |
|
|
|
return result |
|
|
@ -66,10 +69,10 @@ def start_unzip_task(): |
|
|
|
def start_collation_task(): |
|
|
|
def start_collation_task(): |
|
|
|
logger.info('开始整理文件夹') |
|
|
|
logger.info('开始整理文件夹') |
|
|
|
for folder in file_obj.get_root_folder_list(): |
|
|
|
for folder in file_obj.get_root_folder_list(): |
|
|
|
file_col_obj = file.FilesCollection(folder) |
|
|
|
folder_path = os.path.join(root_path, folder) |
|
|
|
|
|
|
|
file_col_obj = file.FilesCollection(folder_path) |
|
|
|
if db_obj.get_data_by_id(folder) and folder not in unzip_failed: |
|
|
|
if db_obj.get_data_by_id(folder) and folder not in unzip_failed: |
|
|
|
logger.info(f'开始整理 {folder}') |
|
|
|
logger.info(f'开始整理 {folder}') |
|
|
|
folder_path = os.path.join(root_path, folder) |
|
|
|
|
|
|
|
# 清除多余的文件 |
|
|
|
# 清除多余的文件 |
|
|
|
file_col_obj.clear_files() |
|
|
|
file_col_obj.clear_files() |
|
|
|
# 整理无效文件夹 |
|
|
|
# 整理无效文件夹 |
|
|
@ -86,16 +89,16 @@ def start_collation_task(): |
|
|
|
def main(): |
|
|
|
def main(): |
|
|
|
n = 1 |
|
|
|
n = 1 |
|
|
|
# unzip_result = False |
|
|
|
# unzip_result = False |
|
|
|
while n <= 3: |
|
|
|
while n <= 5: |
|
|
|
logger.info(f'第{n}轮解压任务') |
|
|
|
logger.info(f'第{n}轮解压任务') |
|
|
|
unzip_result = start_unzip_task() |
|
|
|
unzip_result = start_unzip_task() |
|
|
|
if unzip_result: |
|
|
|
if unzip_result: |
|
|
|
break |
|
|
|
break |
|
|
|
n += 1 |
|
|
|
n += 1 |
|
|
|
logger.info('失败的任务:') |
|
|
|
|
|
|
|
logger.info(', '.join(unzip_failed)) |
|
|
|
|
|
|
|
# if unzip_result: |
|
|
|
# if unzip_result: |
|
|
|
start_collation_task() |
|
|
|
start_collation_task() |
|
|
|
|
|
|
|
logger.info('失败的任务:') |
|
|
|
|
|
|
|
logger.info(', '.join(unzip_failed)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|