优化ucloud的日志及重试机制

This commit is contained in:
2024-07-22 17:31:32 +08:00
parent c06796d0a3
commit ee86bb4e74
10 changed files with 124 additions and 86 deletions

View File

@@ -9,7 +9,7 @@ from db import MysqlSession
from db.mysql import ZxPhrec, ZxPhhd
from photo_mask import OCR, PHHD_BATCH_SIZE, SLEEP_MINUTES, COPY_TRY_TIMES, UPLOAD_TRY_TIMES, NAME_KEYS, \
ID_CARD_NUM_KEYS
from ucloud import BUCKET, ucloud
from ucloud import BUCKET, ufile
from util import image_util, util
@@ -150,7 +150,7 @@ def photo_mask(pk_phhd, name, id_card_num):
)).all()
session.close()
for phrec in phrecs:
img_url = ucloud.get_private_url(phrec.cfjaddress)
img_url = ufile.get_private_url(phrec.cfjaddress)
if not img_url:
continue
# 是否有涂抹
@@ -178,7 +178,7 @@ def photo_mask(pk_phhd, name, id_card_num):
# 如果涂抹了要备份以及更新
if is_masked:
for i in range(COPY_TRY_TIMES):
is_copy_success = ucloud.copy_file(BUCKET, phrec.cfjaddress, "drg2015", phrec.cfjaddress)
is_copy_success = ufile.copy_file(BUCKET, phrec.cfjaddress, "drg2015", phrec.cfjaddress)
if is_copy_success:
break
@@ -186,7 +186,7 @@ def photo_mask(pk_phhd, name, id_card_num):
cv2.imwrite(temp_file.name, image)
try:
for i in range(UPLOAD_TRY_TIMES):
is_upload_success = ucloud.upload_file(phrec.cfjaddress, temp_file.name)
is_upload_success = ufile.upload_file(phrec.cfjaddress, temp_file.name)
if is_upload_success:
break
except Exception as e: