Improve UI cohesion, status bar, and core attack reliability

This commit is contained in:
Dr Jones
2026-05-22 17:51:33 -07:00
parent c958a06b96
commit 1152a937f7
13 changed files with 612 additions and 189 deletions

View File

@@ -16,9 +16,23 @@ class AttemptLogger:
def __init__(self, log_path: Optional[Path] = None):
self.log_path = log_path or ATTEMPT_LOG_FILE
self.buffer = [] # In-memory list of log entries for GUI display
self.buffer = []
self._lock = threading.Lock()
self._init_csv()
self.load_history_from_disk(limit=5000)
def load_history_from_disk(self, limit: int = 5000):
"""Load persisted CSV rows into the in-memory buffer for the GUI."""
if not self.log_path.exists():
return
try:
with open(self.log_path, newline="", encoding="utf-8") as f:
rows = list(csv.DictReader(f))
with self._lock:
self.buffer = rows[-limit:]
except Exception as exc:
logger = logging.getLogger(__name__)
logger.warning(f"Could not load attempt log history: {exc}")
def _init_csv(self):
"""Create CSV with headers if it doesn't exist."""
@@ -76,8 +90,8 @@ class AttemptLogger:
"""Get aggregate statistics from the log."""
with self._lock:
total = len(self.buffer)
successes = sum(1 for e in self.buffer if e["result"] == "SUCCESS")
failures = total - successes
successes = sum(1 for e in self.buffer if e.get("result") == "SUCCESS")
failures = total - successes
return {
"total": total,
"successes": successes,