190 build - улучшение работы всего сервиса. часть 1
This commit is contained in:
@@ -5,6 +5,10 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
<<<<<<< HEAD
|
||||
import logging
|
||||
=======
|
||||
>>>>>>> e4bedb1264fca8a6bc8a41f0ca1ff67b176c6651
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
@@ -354,7 +358,11 @@ def get_khl_site_player_profile(khl_id: int) -> dict[str, Any]:
|
||||
fields = parse_khl_player_profile_html(html)
|
||||
except Exception as exc:
|
||||
_PLAYER_SITE_FAILURES[key] = now
|
||||
<<<<<<< HEAD
|
||||
logging.getLogger("hockey.khl").warning("KHL profile %s: %s", khl_id, exc)
|
||||
=======
|
||||
print(f"KHL profile {khl_id}: {exc}", file=sys.stderr)
|
||||
>>>>>>> e4bedb1264fca8a6bc8a41f0ca1ff67b176c6651
|
||||
return dict(fields)
|
||||
|
||||
with PLAYER_SITE_CACHE_LOCK:
|
||||
@@ -368,7 +376,11 @@ def get_khl_site_player_profile(khl_id: int) -> dict[str, Any]:
|
||||
try:
|
||||
_save_player_site_cache()
|
||||
except OSError as exc:
|
||||
<<<<<<< HEAD
|
||||
logging.getLogger("hockey.khl").error("Не удалось записать кэш профиля KHL %s: %s", khl_id, exc)
|
||||
=======
|
||||
print(f"Не удалось записать кэш профиля KHL {khl_id}: {exc}", file=sys.stderr)
|
||||
>>>>>>> e4bedb1264fca8a6bc8a41f0ca1ff67b176c6651
|
||||
return dict(fields)
|
||||
|
||||
|
||||
@@ -549,7 +561,11 @@ def get_khl_site_player_matches(khl_id: int, page: int = 1) -> dict[str, Any]:
|
||||
tmp.write_text(json.dumps({"fetched_at": now, "payload": payload}, ensure_ascii=False, separators=(",", ":")), encoding="utf-8")
|
||||
tmp.replace(cache_file)
|
||||
except OSError as exc:
|
||||
<<<<<<< HEAD
|
||||
logging.getLogger("hockey.khl").error("Не удалось записать кэш матчей KHL %s/%s: %s", khl_id, page, exc)
|
||||
=======
|
||||
print(f"Не удалось записать кэш матчей KHL {khl_id}/{page}: {exc}", file=sys.stderr)
|
||||
>>>>>>> e4bedb1264fca8a6bc8a41f0ca1ff67b176c6651
|
||||
return payload
|
||||
|
||||
|
||||
@@ -823,7 +839,11 @@ def sync_storage() -> dict[str, Any]:
|
||||
_STORAGE_STATUS = _STORAGE_SYNC(STORE)
|
||||
except Exception as exc:
|
||||
_STORAGE_STATUS = {"mode": "database", "ok": False, "message": "Файлы КХЛ сохранены, импорт в БД не выполнен. Нажмите «Перечитать данные» для повторной попытки."}
|
||||
<<<<<<< HEAD
|
||||
logging.getLogger("hockey.khl").exception("KHL database import failed: %s", type(exc).__name__)
|
||||
=======
|
||||
print(f"KHL database import failed: {type(exc).__name__}", file=sys.stderr)
|
||||
>>>>>>> e4bedb1264fca8a6bc8a41f0ca1ff67b176c6651
|
||||
return dict(_STORAGE_STATUS)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user