Files
TDI-Dashboard/Tool/config.py
T
Luca Banfi e9d07162d9
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
lint syntax fixes
2026-05-18 16:25:52 +02:00

48 lines
1.3 KiB
Python

import os
from collections import deque
from enum import StrEnum
from pathlib import Path
from dotenv import load_dotenv
# Tool/ is one level below RPA_dashboard/
REPORTS_DIR = Path(__file__).resolve().parent.parent
load_dotenv(REPORTS_DIR / '.env')
TMPL_DIR = REPORTS_DIR / "templates"
CSS_PATH = REPORTS_DIR / "static" / "css" / "style.css"
PAGES_CSS_DIR = REPORTS_DIR / "static" / "css"
JS_DIR = REPORTS_DIR / "static" / "js"
class DbType(StrEnum):
REG_LOMB = 'reg_Lomb'
INTRAZ = 'Intraz'
UNKNOWN = 'unknown'
_db_dir_env = os.environ.get('RPA_DB_DIR', '')
DB_DEFAULT_DIR = Path(_db_dir_env) if _db_dir_env else REPORTS_DIR.parent / "data_rpa" / "db"
try:
LOGS_PER_PAGE = max(1, int(os.environ.get('LOGS_ROWS', '30').strip()))
except (ValueError, TypeError):
LOGS_PER_PAGE = 30
try:
STEPS_ROWS = max(1, int(os.environ.get('STEPS_ROWS', '15').strip()))
except (ValueError, TypeError):
STEPS_ROWS = 15
_access_log: deque = deque(maxlen=200)
_state: dict = {'db_path': '', 'db_type': DbType.UNKNOWN}
# Authentication — mutable so settings can be updated at runtime
_auth: dict = {
'enabled': os.environ.get('LOGIN', 'true').strip().lower() != 'false',
'user': os.environ.get('DASHBOARD_USER', ''),
'password': os.environ.get('DASHBOARD_PASSWORD', ''),
}
_sessions: set = set() # active session tokens