26 lines
917 B
Python
26 lines
917 B
Python
# 辅助函数 (例如截图、报告生成)
|
||
import asyncio
|
||
import os
|
||
|
||
# 辅助函数,模拟对象存储上传
|
||
async def upload_file_to_s3(local_path: str, remote_path: str) -> str:
|
||
"""
|
||
模拟将文件上传到S3(或任何对象存储)并返回可访问URL。
|
||
在实际项目中,这里会调用 AWS SDK, MinIO SDK 等。
|
||
"""
|
||
if not os.path.exists(local_path):
|
||
return "" # 文件不存在则不上传
|
||
|
||
# 模拟上传延迟
|
||
await asyncio.sleep(0.1)
|
||
print(f"Mock Uploaded {local_path} to S3 bucket/path: {remote_path}")
|
||
# 返回一个模拟的URL
|
||
return f"https://your-s3-bucket.com/{remote_path}"
|
||
|
||
# 其他通用工具函数,例如日志格式化,报告生成辅助等。
|
||
def scalar_map_to_dict(scalar_map):
|
||
"""将 protobuf ScalarMap 转换为普通 Python dict"""
|
||
if not scalar_map:
|
||
return {}
|
||
return {k: v for k, v in scalar_map.items()}
|