This commit is contained in:
2026-02-08 19:03:00 +01:00
parent 38c0595c81
commit 0b03fed798
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,17 @@
Ziel-Struktur: alles in einem Verzeichnis
Beispiel: ~/mmp_logger/
```
mmp_logger/
├─ mmp_logger.py
├─ requirements.txt
├─ config.json
├─ cost_centers.json
├─ data/
│ └─ mmp.sqlite
├─ logs/
│ └─ mmp_logger.log
└─ reports/
├─ report_weekly.md
├─ report_weekly.html
└─ report_weekly.pdf (optional)
```

View File

@ -11,6 +11,7 @@ import telnetlib
import time
from dataclasses import dataclass
from typing import Dict, List, Optional, Tuple
from pathlib import Path
PROMPT_RE = re.compile(rb".*> ?$") # Prompt endet mit '>'
NUM_RE = re.compile(r"([-+]?\d+(\.\d+)?)")
@ -23,6 +24,12 @@ class DeviceCfg:
enabled: bool = True
username: Optional[str] = None
password: Optional[str] = None
def resolve_path(base_file: str, maybe_rel: str) -> str:
p = Path(maybe_rel)
if p.is_absolute():
return str(p)
return str(Path(base_file).resolve().parent / p)
def utc_now_iso() -> str:
return dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat()
@ -434,6 +441,10 @@ def main():
args = ap.parse_args()
cfg = load_json(args.config)
cfg_path = args.config
db_path = resolve_path(cfg_path, cfg["db_path"])
cc_path = resolve_path(cfg_path, cfg["cost_center_map"])
cc_map = load_json(cc_path)
cc_map = load_json(cfg["cost_center_map"])
db_path = cfg["db_path"]

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
markdown