Files
leopold.stroblandClaude Opus 4.8 bdcb17285c Watch EPIRent version and archive its download packages
- Poll the public download page for "Aktuelle Version <nr> vom <date>",
  report changes through the normal change feed and notification mail,
  and show the current version as a card on the overview. Runs on its own
  interval (default 30 min); the first run only records a baseline.
- Archive epirentServer.zip / epirentClient.zip per version number so we
  keep a download cache and history: streamed to disk with SHA-256 and
  size, fetched in a background thread so ticket polling is unaffected,
  with a free-space check before downloading (~1.1 GB per version).
- Retention is configurable via EPIRENT_DOWNLOAD_KEEP, where 0 means
  unlimited; a successful archive is reported as a change and by mail.
- New Downloads page listing the archived versions with checksums and
  links to fetch the cached files.
- Notification lines now omit the arrow when there is no previous value
  and drop the "#" for entries without a ticket.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 15:12:48 +02:00

66 lines
2.4 KiB
Python

"""Zentrale Konfiguration, geladen aus der .env-Datei."""
import os
from pathlib import Path
from dotenv import load_dotenv
# Projektwurzel = ein Verzeichnis über diesem File
BASE_DIR = Path(__file__).resolve().parent.parent
load_dotenv(BASE_DIR / ".env")
DATA_DIR = BASE_DIR / "data"
DATA_DIR.mkdir(exist_ok=True)
DB_PATH = DATA_DIR / "episupport.db"
def _b(value: str, default: bool = False) -> bool:
if value is None:
return default
return value.strip().lower() in ("1", "true", "yes", "on", "ja")
# --- Zammad ---
ZAMMAD_URL = os.getenv("ZAMMAD_URL", "https://epi-helpdesk.zammad.com").rstrip("/")
ZAMMAD_TOKEN = os.getenv("ZAMMAD_TOKEN", "").strip()
ZAMMAD_USER = os.getenv("ZAMMAD_USER", "").strip()
ZAMMAD_PASSWORD = os.getenv("ZAMMAD_PASSWORD", "")
# --- Abruf ---
POLL_INTERVAL_SECONDS = int(os.getenv("POLL_INTERVAL_SECONDS", "180"))
# --- EPIRent-Versionsüberwachung (Download-Seite) ---
EPIRENT_CHECK_ENABLED = _b(os.getenv("EPIRENT_CHECK_ENABLED"), True)
EPIRENT_URL = os.getenv("EPIRENT_URL", "https://www.epi.rent/downloads")
EPIRENT_CHECK_INTERVAL_SECONDS = int(
os.getenv("EPIRENT_CHECK_INTERVAL_SECONDS", "1800"))
# --- Download-Archiv (pro Version zwischengespeichert) ---
EPIRENT_DOWNLOAD_ENABLED = _b(os.getenv("EPIRENT_DOWNLOAD_ENABLED"), True)
EPIRENT_DOWNLOAD_URLS = [
u.strip() for u in os.getenv(
"EPIRENT_DOWNLOAD_URLS",
"https://download.epi.rent/latest/epirentServer.zip,"
"https://download.epi.rent/latest/epirentClient.zip"
).split(",") if u.strip()
]
# Wie viele Versionsstände aufbewahrt werden (je ~1,1 GB!).
# 0 = unbegrenzt aufbewahren (es wird nichts automatisch gelöscht).
EPIRENT_DOWNLOAD_KEEP = int(os.getenv("EPIRENT_DOWNLOAD_KEEP", "3"))
# --- Web ---
URL_PREFIX = os.getenv("EPISUPPORT_URL_PREFIX", "/episupport").rstrip("/")
PORT = int(os.getenv("EPISUPPORT_PORT", "8071"))
# Zeitzone für die Anzeige (Zammad liefert UTC)
DISPLAY_TZ = os.getenv("DISPLAY_TZ", "Europe/Berlin")
# --- E-Mail ---
NOTIFY_ENABLED = _b(os.getenv("NOTIFY_ENABLED"), False)
SMTP_HOST = os.getenv("SMTP_HOST", "").strip()
SMTP_PORT = int(os.getenv("SMTP_PORT", "587"))
SMTP_USER = os.getenv("SMTP_USER", "").strip()
SMTP_PASSWORD = os.getenv("SMTP_PASSWORD", "")
SMTP_STARTTLS = _b(os.getenv("SMTP_STARTTLS"), True)
SMTP_SSL = _b(os.getenv("SMTP_SSL"), False) # True => SMTPS (Port 465)
SMTP_FROM = os.getenv("SMTP_FROM", "").strip()
NOTIFY_TO = [a.strip() for a in os.getenv("NOTIFY_TO", "").split(",") if a.strip()]