fix
This commit is contained in:
parent
478ca29fa9
commit
0bcc514aa9
|
@ -23,17 +23,10 @@ class S:
|
||||||
collection="image"
|
collection="image"
|
||||||
)
|
)
|
||||||
print(self.col_image)
|
print(self.col_image)
|
||||||
self.del_images = list()
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
cnt = 0
|
|
||||||
for lp in self.del_images:
|
|
||||||
os.remove(lp)
|
|
||||||
cnt += 1
|
|
||||||
print("{} files removed".format(cnt))
|
|
||||||
self.col_image.close()
|
self.col_image.close()
|
||||||
|
|
||||||
|
|
||||||
def upload_img_to_oss(self, local_path: str, oss_src_id: str):
|
def upload_img_to_oss(self, local_path: str, oss_src_id: str):
|
||||||
return self.bucket.put_object_from_file(oss_src_id, local_path)
|
return self.bucket.put_object_from_file(oss_src_id, local_path)
|
||||||
|
|
||||||
|
@ -44,8 +37,12 @@ class S:
|
||||||
def proc_oen(self):
|
def proc_oen(self):
|
||||||
# 获取所有heic图片
|
# 获取所有heic图片
|
||||||
q = {"fmt": "image/heic"}
|
q = {"fmt": "image/heic"}
|
||||||
images = self.col_image.find(q, limit=1)
|
images = self.col_image.find(q)
|
||||||
|
print(len(images))
|
||||||
|
return
|
||||||
|
|
||||||
idx = 0
|
idx = 0
|
||||||
|
del_images = list()
|
||||||
for img in images:
|
for img in images:
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
|
@ -55,7 +52,7 @@ class S:
|
||||||
|
|
||||||
arr = old_key.split("/")
|
arr = old_key.split("/")
|
||||||
local_path = arr[len(arr) - 1] + ".jpeg"
|
local_path = arr[len(arr) - 1] + ".jpeg"
|
||||||
self.del_images.append(local_path)
|
del_images.append(local_path)
|
||||||
|
|
||||||
ret_save = self.heic_to_jpg_and_save(old_key, local_path)
|
ret_save = self.heic_to_jpg_and_save(old_key, local_path)
|
||||||
ret_save_status = ret_save.resp.status
|
ret_save_status = ret_save.resp.status
|
||||||
|
@ -84,6 +81,10 @@ class S:
|
||||||
mongo_ret = self.col_image.update_one(q, up)
|
mongo_ret = self.col_image.update_one(q, up)
|
||||||
logger.Info("{}, heic2jpeg finish, new_key: {}, mongo_modify: {}".format(idx, new_key, mongo_ret.modified_count))
|
logger.Info("{}, heic2jpeg finish, new_key: {}, mongo_modify: {}".format(idx, new_key, mongo_ret.modified_count))
|
||||||
|
|
||||||
|
for lp in del_images:
|
||||||
|
os.remove(lp)
|
||||||
|
logger.Info("{} files removed".format(len(del_images)))
|
||||||
|
|
||||||
|
|
||||||
s = S()
|
s = S()
|
||||||
s.proc_oen()
|
s.proc_oen()
|
||||||
|
|
Loading…
Reference in New Issue