20-sep: migracion watchers (Telegram+recordatorios) a INFRAESTRUCTURA + estado/agentes/changelog

This commit is contained in:
juanminsanz
2026-09-20 12:42:16 +02:00
parent 5e8ae0c394
commit 143f9810b0
18 changed files with 1315 additions and 7 deletions

48
scripts/infra_paths.py Normal file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""infra_paths.py — Resolucion de rutas compartidas del repo INFRAESTRUCTURA.
Los scripts de infraestructura viven en `INFRAESTRUCTURA/scripts/` y necesitan:
- Estado runtime propio del repo -> `INFRAESTRUCTURA/estado/`
- Datos de negocio y modulos aun compartidos del repo
`biblioteca_negocio_prolongo` -> pendientes.json, idd_channel, netatmo_tool, alarma_twilio
La ubicacion del repo de negocio se resuelve asi (por orden):
1. Variable de entorno `BIBLIOTECA_REPO`
2. Repo hermano de INFRAESTRUCTURA: `../biblioteca_negocio_prolongo`
En el portatil la estructura de carpetas es la misma (`Documents/GitHub/...`), por lo
que el hermano funciona sin configurar nada; `BIBLIOTECA_REPO` permite sobreescribirlo.
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
INFRA_ROOT = Path(__file__).resolve().parent.parent
SCRIPTS_DIR = INFRA_ROOT / "scripts"
ESTADO_DIR = INFRA_ROOT / "estado"
def biblioteca_repo() -> Path:
"""Devuelve la ruta del repo de negocio (biblioteca_negocio_prolongo)."""
env = os.environ.get("BIBLIOTECA_REPO")
if env:
return Path(env).expanduser().resolve()
return (INFRA_ROOT.parent / "biblioteca_negocio_prolongo").resolve()
def bootstrap_biblioteca_paths() -> Path:
"""Anade al sys.path los modulos que aun viven en el repo de negocio.
Transitorio: `idd_channel`, `netatmo_tool` y `alarma_twilio` siguen en
biblioteca_negocio_prolongo porque los bots del VPS los importan desde alli.
Cuando se centralicen en INFRAESTRUCTURA, esta funcion quedara vacia.
"""
repo = biblioteca_repo()
for candidato in (repo, repo / "scripts"):
sp = str(candidato)
if candidato.exists() and sp not in sys.path:
sys.path.insert(0, sp)
return repo