collect: re-login on AuthentificationError after weconnect exhausts its own retry
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,7 @@ from datetime import datetime, timezone
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from server import log_config, network, we_connect
|
from server import log_config, network, we_connect
|
||||||
|
from weconnect.errors import AuthentificationError
|
||||||
from server.data_model import ALL_DOMAINS, collect_snapshot, apply_procedural
|
from server.data_model import ALL_DOMAINS, collect_snapshot, apply_procedural
|
||||||
from server.storage_helpers import auto_out_path, load_last_24h_records, load_store, save_store
|
from server.storage_helpers import auto_out_path, load_last_24h_records, load_store, save_store
|
||||||
from utils.jay_diff import jay_diff_full
|
from utils.jay_diff import jay_diff_full
|
||||||
@@ -145,6 +146,12 @@ def run(args: argparse.Namespace) -> None:
|
|||||||
log.info("Record #%d saved at %s", len(store["records"]), snapshot["ts"])
|
log.info("Record #%d saved at %s", len(store["records"]), snapshot["ts"])
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
|
except AuthentificationError:
|
||||||
|
log.warning("Authentication error — re-logging in before next interval")
|
||||||
|
try:
|
||||||
|
wc.login()
|
||||||
|
except Exception:
|
||||||
|
log.exception("Re-login failed")
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("Collection failed — will retry at next interval")
|
log.exception("Collection failed — will retry at next interval")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user