WeatherLink : branchement dans le tick et la publication (etat, attribution) + tests avec reponses simulees
Cette révision appartient à :
1 Parent
b8fd17d0e6
révision
fb235a2c85
3 fichiers modifiés
+220
-2
Aucun fichier ne correspond à votre recherche
@@ -13,13 +13,13 @@ ni l'autre source ni la publication.
|
||||
import datetime as dt
|
||||
import sys
|
||||
|
||||
from . import infoclimat, publier, romma
|
||||
from . import infoclimat, publier, romma, weatherlink
|
||||
from .commun import UTC, Config, Journal, Verrou, lire_json
|
||||
from .stockage import Stockage
|
||||
|
||||
|
||||
def tick(cfg, maintenant=None, fetch_infoclimat=infoclimat.telecharger, fetch_romma=romma.telecharger,
|
||||
appels=True):
|
||||
appels=True, fetch_weatherlink=weatherlink.telecharger, dormir_weatherlink=None):
|
||||
maintenant = maintenant or dt.datetime.now(UTC)
|
||||
var = cfg.base / "var"
|
||||
journal = Journal(var / "collecte.log")
|
||||
@@ -32,6 +32,9 @@ def tick(cfg, maintenant=None, fetch_infoclimat=infoclimat.telecharger, fetch_ro
|
||||
if appels and cfg.romma_actif:
|
||||
resumes["romma"] = _sans_planter(journal, maintenant, "romma",
|
||||
lambda: romma.passer(cfg, stockage, journal, maintenant, fetch_romma))
|
||||
if appels and cfg.weatherlink_actif: # opt-in ; quota et état entièrement séparés
|
||||
resumes["weatherlink"] = _sans_planter(journal, maintenant, "weatherlink", lambda: weatherlink.passer(
|
||||
cfg, stockage, journal, maintenant, fetch_weatherlink, dormir_weatherlink))
|
||||
if appels and cfg.infoclimat_actif:
|
||||
stations = lire_json(cfg.stations, {}).get("infoclimat", {})
|
||||
resumes["infoclimat"] = _sans_planter(journal, maintenant, "infoclimat", lambda: infoclimat.passer(
|
||||
@@ -67,6 +70,14 @@ def main(argv=None):
|
||||
print("%-20s définie (valeur masquée)" % nom)
|
||||
except LookupError:
|
||||
print("%-20s absente" % nom)
|
||||
if cfg.weatherlink_actif:
|
||||
for compte, d in lire_json(cfg.weatherlink_comptes, {}).get("comptes", {}).items():
|
||||
for nom in (d.get("var_cle"), d.get("var_secret")):
|
||||
try:
|
||||
cfg.secret(nom)
|
||||
print("%-28s définie (valeur masquée) [compte %s]" % (nom, compte))
|
||||
except LookupError:
|
||||
print("%-28s absente [compte %s]" % (nom, compte))
|
||||
return 0
|
||||
tick(cfg, appels="--publier" not in argv)
|
||||
return 0
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur