优化ucloud日志

This commit is contained in:
2024-07-26 10:47:51 +08:00
parent c95639482f
commit c304d97609

View File

@@ -17,7 +17,7 @@ def get_private_url(key, bucket=BUCKET):
# 判断文件是否存在 # 判断文件是否存在
_, resp = UFILE_HANDLER.head_file(bucket, key) _, resp = UFILE_HANDLER.head_file(bucket, key)
if resp.status_code == -1: if resp.status_code == -1:
UCLOUD_LOGGER.warning(f"查询{key}时uCloud连接失败!") UCLOUD_LOGGER.warning(f"查询({key})时uCloud连接失败!")
raise ConnectionError("uCloud连接失败") raise ConnectionError("uCloud连接失败")
if resp.status_code != 200: if resp.status_code != 200:
UCLOUD_LOGGER.warning(f"[{bucket}]中未找到({key})! status: {resp.status_code} error: {resp.error}") UCLOUD_LOGGER.warning(f"[{bucket}]中未找到({key})! status: {resp.status_code} error: {resp.error}")
@@ -37,7 +37,7 @@ def copy_file(source_bucket, source_key, target_bucket, target_key):
# 复制文件 # 复制文件
_, resp = UFILE_HANDLER.copy(target_bucket, target_key, source_bucket, source_key) _, resp = UFILE_HANDLER.copy(target_bucket, target_key, source_bucket, source_key)
if resp.status_code == -1: if resp.status_code == -1:
UCLOUD_LOGGER.warning(f"复制{source_key}时uCloud连接失败!") UCLOUD_LOGGER.warning(f"复制({source_key})时uCloud连接失败!")
return False return False
if resp.status_code != 200: if resp.status_code != 200:
UCLOUD_LOGGER.warning( UCLOUD_LOGGER.warning(
@@ -53,7 +53,7 @@ def upload_file(key, file_path, bucket=BUCKET):
# 普通上传文件至云空间 # 普通上传文件至云空间
_, resp = UFILE_HANDLER.putfile(bucket, key, file_path, header=None) _, resp = UFILE_HANDLER.putfile(bucket, key, file_path, header=None)
if resp.status_code == -1: if resp.status_code == -1:
UCLOUD_LOGGER.warning(f"上传{key}时uCloud连接失败!") UCLOUD_LOGGER.warning(f"上传({key})时uCloud连接失败!")
return False return False
if resp.status_code != 200: if resp.status_code != 200:
UCLOUD_LOGGER.warning(f"上传({key})失败! status: {resp.status_code} error: {resp.error}") UCLOUD_LOGGER.warning(f"上传({key})失败! status: {resp.status_code} error: {resp.error}")