-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
64 lines (51 loc) · 1.81 KB
/
Copy pathconfig.py
File metadata and controls
64 lines (51 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# config.py
import sys
from pathlib import Path
def _candidate_roots():
"""Liefert mögliche gemeinsame Ordner für Python- und EXE-Starts."""
if getattr(sys, "frozen", False):
executable_dir = Path(sys.executable).resolve().parent
roots = [
executable_dir,
executable_dir.parent,
executable_dir.parent.parent,
]
else:
roots = [Path(__file__).resolve().parent.parent]
roots.append(Path.cwd().resolve())
return list(dict.fromkeys(roots))
def _find_log_files(application, filename):
"""Findet Logs neben dem Quellordner und in dessen dist-Verzeichnis."""
candidates = []
for root in _candidate_roots():
for candidate in (
root / application / filename,
root / application / "dist" / filename,
):
if candidate.exists() and candidate not in candidates:
candidates.append(candidate)
if candidates:
return [str(candidate) for candidate in candidates]
root = _candidate_roots()[0]
return [str(root / application / filename)]
LOG_FILE_PATHS = [
path
for application, filename in (
("system_monitor", "system_monitor.log"),
("netzwerk_monitor", "netzwerk_monitor.log"),
)
for path in _find_log_files(application, filename)
]
KEYWORDS = ["ERROR", "CRITICAL", "WARNING", "Exception", "FAIL"]
POLL_INTERVAL = 0.5
"""
# Pfad zur zu überwachenden Logdatei (Standard: eine lokale Test-Logdatei)
LOG_FILE_PATH = [
"/home/dell/Schreibtisch/system_monitor/system_monitor.log",
"/home/dell/Schreibtisch/netzwerk_monitor/netzwerk_monitor.log"
]
# Zu überwachende Schlüsselwörter / Muster
KEYWORDS = ["ERROR", "CRITICAL", "WARNING", "Exception", "FAIL"]
# Abfrage-Intervall in Sekunden für den Dateizugriff
POLL_INTERVAL = 0.5
"""