输出内容更详细一些

This commit is contained in:
lededev
2021-09-26 09:49:28 +08:00
parent 6a4739c035
commit 948a3d20b0
2 changed files with 11 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ import typing
import urllib3 import urllib3
import config import config
import datetime from datetime import datetime
import time import time
from pathlib import Path from pathlib import Path
from ADC_function import file_modification_days, get_html, is_link from ADC_function import file_modification_days, get_html, is_link
@@ -101,7 +101,7 @@ def dupe_stdout_to_logfile(logdir: str):
if not os.path.isdir(logdir): if not os.path.isdir(logdir):
return return
log_tmstr = datetime.datetime.now().strftime("%Y%m%dT%H%M%S") log_tmstr = datetime.now().strftime("%Y%m%dT%H%M%S")
logfile = os.path.join(logdir, f'avdc_{log_tmstr}.txt') logfile = os.path.join(logdir, f'avdc_{log_tmstr}.txt')
errlog = os.path.join(logdir, f'avdc_{log_tmstr}_err.txt') errlog = os.path.join(logdir, f'avdc_{log_tmstr}_err.txt')

15
core.py
View File

@@ -10,6 +10,7 @@ import sys
from PIL import Image from PIL import Image
from io import BytesIO from io import BytesIO
from pathlib import Path from pathlib import Path
from datetime import datetime
from ADC_function import * from ADC_function import *
from WebCrawler import get_data_from_json from WebCrawler import get_data_from_json
@@ -28,16 +29,18 @@ def moveFailedFolder(filepath, conf):
# 模式3或软连接改为维护一个失败列表启动扫描时加载用于排除该路径以免反复处理 # 模式3或软连接改为维护一个失败列表启动扫描时加载用于排除该路径以免反复处理
# 原先的创建软连接到失败目录,并不直观,不方便找到失败文件位置,不如直接记录该文件路径 # 原先的创建软连接到失败目录,并不直观,不方便找到失败文件位置,不如直接记录该文件路径
if conf.main_mode() == 3 or soft_link: if conf.main_mode() == 3 or soft_link:
with open(os.path.join(failed_folder, 'failed_list.txt'), 'a', encoding='utf-8') as flt: ftxt = os.path.join(failed_folder, 'failed_list.txt')
print("[-]Add to Failed List file, see '%s'" % ftxt)
with open(ftxt, 'a', encoding='utf-8') as flt:
flt.write(f'{filepath}\n') flt.write(f'{filepath}\n')
flt.close() flt.close()
print('[-]Add to failed list file, see failed_list.txt')
elif conf.failed_move() and not soft_link: elif conf.failed_move() and not soft_link:
failed_name = os.path.join(failed_folder, os.path.basename(filepath)) failed_name = os.path.join(failed_folder, os.path.basename(filepath))
print('[-]Move to Failed output folder, see where_was_i_before_being_moved.txt') mtxt = os.path.join(failed_folder, 'where_was_i_before_being_moved.txt')
with open(os.path.join(failed_folder, 'where_was_i_before_being_moved.txt'), 'a', print("'[-]Move to Failed output folder, see '%s'" % mtxt)
encoding='utf-8') as wwibbmt: with open(mtxt, 'a', encoding='utf-8') as wwibbmt:
wwibbmt.write(f'FROM[{filepath}]TO[{failed_name}]\n') tmstr = datetime.now().strftime("%Y-%m-%d %H:%M")
wwibbmt.write(f'{tmstr} FROM[{filepath}]TO[{failed_name}]\n')
wwibbmt.close() wwibbmt.close()
shutil.move(filepath, failed_name) shutil.move(filepath, failed_name)