Commit 0c4f4ead by Peng

no message

parent b1700260
......@@ -215,12 +215,14 @@ class UploadPicture():
image_extensions = ['.jpg', '.jpeg', '.png']
# 获取文件夹中所有支持的图像文件,并按最后修改时间排序
files = []
for file_name in os.listdir(folder_path):
if any(file_name.lower().endswith(ext) for ext in image_extensions):
file_path = os.path.join(folder_path, file_name)
mtime = os.path.getmtime(file_path)
files.append((file_name, mtime))
try:
for file_name in os.listdir(folder_path):
if any(file_name.lower().endswith(ext) for ext in image_extensions):
file_path = os.path.join(folder_path, file_name)
mtime = os.path.getmtime(file_path)
files.append((file_name, mtime))
except:
return 'null'
# 按文件的最后修改时间排序
files_sorted = sorted(files, key=lambda x: x[1])
# 成功后转移
......@@ -240,7 +242,7 @@ class UploadPicture():
print('转移到上传成功的文件夹中')
shutil.move(file_path, os.path.join(all_pic_success_dir, file_name))
pass
return 1
def run(self):
folder_path_list = [
......@@ -279,7 +281,7 @@ class UploadPicture():
if 9 <= datetime.now().hour < 16:
print(f"当前时间 {datetime.now().hour} 点,超出运行时段 18:00–08:00,退出循环。")
break
print(f"当前时间 {datetime.now().hour} 点,开始处理账户 {account_id}")
print(f"当前时间 {datetime.now().hour} 点,开始处理账户 {account_id}")
if '@' in account_id:
account_id_tmp = account_id.split('@')[0]
else:
......@@ -288,9 +290,11 @@ class UploadPicture():
print('folder_path:::',folder_path)
# 带重试地执行上传目录
success = False
for attempt in range(1): # 最多重试3次
for attempt in range(3): # 最多重试3次
try:
self.upload_dir(folder_path)
str_null = self.upload_dir(folder_path)
if str_null == 'null':
break
success = True
break
except (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment