anlegen
This commit is contained in:
17
README.md
17
README.md
@ -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)
|
||||
```
|
||||
|
||||
@ -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+)?)")
|
||||
@ -24,6 +25,12 @@ class DeviceCfg:
|
||||
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
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
markdown
|
||||
Reference in New Issue
Block a user