1
This commit is contained in:
1 parent
0d5d9d9289
commit
20c79b5bc0
1 file changed
+59
-1
+59
-1
@@ -378,4 +378,62 @@ def down_obj_from_oss_auto(pid,action,pathStr):
|
|||||||
|
|
||||||
print(filename)
|
print(filename)
|
||||||
localfile = os.path.join(pathStr, filename)
|
localfile = os.path.join(pathStr, filename)
|
||||||
config.oss_bucket.get_object_to_file(file.key, localfile)
|
config.oss_bucket.get_object_to_file(file.key, localfile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def down_from_oss_photo2(oss_client, workdir, pid, per=100,photoPath=""):
|
||||||
|
start_time = time.time()
|
||||||
|
path = os.path.join(workdir, pid)
|
||||||
|
if os.path.exists(path):
|
||||||
|
print(f"Directory {path} already exists, skip")
|
||||||
|
return
|
||||||
|
# os.makedirs(os.path.join(path, 'photo1'))
|
||||||
|
os.makedirs(os.path.join(path, 'photo2'))
|
||||||
|
|
||||||
|
psid = getPSid(pid)
|
||||||
|
# 根据前缀获取文件列表
|
||||||
|
prefix = f'photos/{pid}/photo2'
|
||||||
|
filelist = oss2.ObjectIteratorV2(oss_client, prefix=prefix)
|
||||||
|
for file in tqdm(filelist):
|
||||||
|
filename = file.key.split('/')[-1]
|
||||||
|
localfile = ""
|
||||||
|
# print('正在下载:', file.key)
|
||||||
|
if photoPath == "":
|
||||||
|
if filename.endswith('_1.jpg'):
|
||||||
|
localfile = os.path.join(path, 'photo1', filename)
|
||||||
|
else:
|
||||||
|
localfile = os.path.join(path, 'photo2', filename)
|
||||||
|
else:
|
||||||
|
if photoPath=="1":
|
||||||
|
if filename.endswith('_1.jpg'):
|
||||||
|
localfile = os.path.join(path, 'photo1', filename)
|
||||||
|
else:
|
||||||
|
if filename.endswith('_8.jpg'):
|
||||||
|
localfile = os.path.join(path, 'photo2', filename)
|
||||||
|
if localfile == "":
|
||||||
|
continue
|
||||||
|
style = f'image/resize,p_{per}'
|
||||||
|
if per == 100:
|
||||||
|
oss_client.get_object_to_file(file.key, localfile)
|
||||||
|
else:
|
||||||
|
oss_client.get_object_to_file(file.key, localfile, process=style)
|
||||||
|
|
||||||
|
#判断localfile 是否有包含 photo2
|
||||||
|
|
||||||
|
|
||||||
|
#遍历处理photo2的数数据
|
||||||
|
# if str(psid) == "96" or str(pid) == "118994":
|
||||||
|
# path = os.path.join(workdir, pid, 'photo2')
|
||||||
|
# files = []
|
||||||
|
# for fileName in os.listdir(path):
|
||||||
|
# if ".jpg" in fileName:
|
||||||
|
# files.append(path+"\\"+fileName)
|
||||||
|
# beginTime = time.time()
|
||||||
|
# with ThreadPoolExecutor(max_workers=6) as executor:
|
||||||
|
# executor.map(process_image, files)
|
||||||
|
|
||||||
|
# print(f'{localfile}灰度处理费时{diff_time(beginTime)}')
|
||||||
|
|
||||||
|
|
||||||
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 图片下载完成, 共费时{diff_time(start_time)}')
|
||||||
Reference in new issue
Block a user