verify-logs.py 1.1 KB

1234567891011121314151617181920
  1. #!/usr/bin/env python3
  2. """下载验证两家日志"""
  3. from obs import ObsClient
  4. import json
  5. obs = ObsClient(access_key_id="2BFF7JWXAIJ0UGNJ0OSB", secret_access_key="NaPCiJCGmD3nklCzX65s8mSK1Py13ueyhgepa0s1",
  6. server="https://obs.cn-north-4.myhuaweicloud.com")
  7. for key in ["user/pODNJqbURI/log/20260829/1424.json", "user/dhv9yTqK6K/log/20260829/1425.json"]:
  8. r = obs.getObject("storage-s3-nkkj", key)
  9. body = r.body.read() if callable(getattr(r.body, "read", None)) else (
  10. r.body.response if hasattr(r.body, "response") else str(r.body))
  11. if isinstance(body, bytes):
  12. d = json.loads(body)
  13. else:
  14. # ObjectStream: 用 stream 属性
  15. d = json.loads(r.body.response.read() if hasattr(r.body, "response") and callable(getattr(r.body.response, "read", None)) else b"{}")
  16. print(f"=== {key.split('/')[1]} ===")
  17. print(" 资源:", json.dumps(d["resources"], ensure_ascii=False)[:220])
  18. print(" 并发:", json.dumps(d["concurrency"], ensure_ascii=False)[:150])
  19. print(" 服务:", json.dumps(d["services"], ensure_ascii=False)[:80])