fix(main): load .env file and respect USE_MOCK_DATA setting
- Add python-dotenv to load .env configuration - Read USE_MOCK_DATA and EU_CHAT_LOG_PATH from environment - Use real game log when USE_MOCK_DATA=false - Show correct mode (Mock vs Live) in header - Import os module for environment access Fixes issue where app always used mock data regardless of .env settings.
This commit is contained in:
parent
bd506e53c2
commit
6ce23718bc
20
main.py
20
main.py
|
|
@ -5,11 +5,17 @@
|
||||||
import sys
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
import signal
|
import signal
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
# Load .env file before anything else
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
env_path = Path(__file__).parent / ".env"
|
||||||
|
load_dotenv(dotenv_path=env_path)
|
||||||
|
|
||||||
# Add core to path
|
# Add core to path
|
||||||
core_dir = Path(__file__).parent / "core"
|
core_dir = Path(__file__).parent / "core"
|
||||||
sys.path.insert(0, str(core_dir))
|
sys.path.insert(0, str(core_dir))
|
||||||
|
|
@ -75,7 +81,10 @@ class LemontropiaApp:
|
||||||
"""Print application header."""
|
"""Print application header."""
|
||||||
print("\n" + "="*65)
|
print("\n" + "="*65)
|
||||||
print(" 🍋 LEMONTROPIA SUITE — User Test Build v0.1.0")
|
print(" 🍋 LEMONTROPIA SUITE — User Test Build v0.1.0")
|
||||||
|
if os.getenv('USE_MOCK_DATA', 'true').lower() in ('true', '1', 'yes'):
|
||||||
print(" Core Data Capture Engine — Mock Mode")
|
print(" Core Data Capture Engine — Mock Mode")
|
||||||
|
else:
|
||||||
|
print(" Core Data Capture Engine — Live Mode")
|
||||||
print("="*65)
|
print("="*65)
|
||||||
print("\n 📚 TERMINOLOGY:")
|
print("\n 📚 TERMINOLOGY:")
|
||||||
print(" • PROJECT = Activity type (Hunt/Mine/Craft)")
|
print(" • PROJECT = Activity type (Hunt/Mine/Craft)")
|
||||||
|
|
@ -184,11 +193,18 @@ class LemontropiaApp:
|
||||||
session = self.pm.start_session(project.id, notes=session_notes)
|
session = self.pm.start_session(project.id, notes=session_notes)
|
||||||
print(f"✅ SESSION started: ID {session.id}")
|
print(f"✅ SESSION started: ID {session.id}")
|
||||||
|
|
||||||
# Setup log watcher
|
# Setup log watcher - use real log or mock based on .env
|
||||||
|
use_mock = os.getenv('USE_MOCK_DATA', 'true').lower() in ('true', '1', 'yes')
|
||||||
|
log_path = os.getenv('EU_CHAT_LOG_PATH', '')
|
||||||
|
|
||||||
|
if use_mock or not log_path:
|
||||||
test_data_dir = Path(__file__).parent / "test-data"
|
test_data_dir = Path(__file__).parent / "test-data"
|
||||||
mock_log = test_data_dir / "mock-chat.log"
|
mock_log = test_data_dir / "mock-chat.log"
|
||||||
|
|
||||||
self.watcher = LogWatcher(str(mock_log), poll_interval=2.0, mock_mode=True)
|
self.watcher = LogWatcher(str(mock_log), poll_interval=2.0, mock_mode=True)
|
||||||
|
logger.info("Using MOCK data for testing")
|
||||||
|
else:
|
||||||
|
self.watcher = LogWatcher(log_path, poll_interval=1.0, mock_mode=False)
|
||||||
|
logger.info(f"Using REAL log: {log_path}")
|
||||||
|
|
||||||
# Stats tracking
|
# Stats tracking
|
||||||
stats = {'loot': 0, 'globals': 0, 'hofs': 0, 'skills': 0, 'total_ped': Decimal('0.0')}
|
stats = {'loot': 0, 'globals': 0, 'hofs': 0, 'skills': 0, 'total_ped': Decimal('0.0')}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue