roughly working again, now dev docker exists
This commit is contained in:
parent
a77a0c0393
commit
155ab39368
26 changed files with 1976 additions and 235 deletions
53
state_manager.py
Normal file
53
state_manager.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import os
|
||||
import dotenv
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
dotenv.load_dotenv() # Load environment variables from .env file
|
||||
|
||||
class StateManager:
|
||||
def __init__(self, state_file: Path):
|
||||
self.state_file = state_file
|
||||
self.logged_in = False # Initialize logged_in attribute
|
||||
|
||||
# Load credentials from environment variables
|
||||
self.email = os.getenv("INBERLIN_EMAIL")
|
||||
self.password = os.getenv("INBERLIN_PASSWORD")
|
||||
|
||||
if not self.email or not self.password:
|
||||
logger.warning("Email or password not set in environment variables.")
|
||||
|
||||
def load_state(self) -> dict:
|
||||
"""Load persistent state"""
|
||||
if self.state_file.exists():
|
||||
with open(self.state_file, "r") as f:
|
||||
return json.load(f)
|
||||
return {"autopilot": False}
|
||||
|
||||
def save_state(self, state: dict):
|
||||
"""Save persistent state"""
|
||||
with open(self.state_file, "w") as f:
|
||||
json.dump(state, f, indent=2)
|
||||
|
||||
def set_autopilot(self, enabled: bool):
|
||||
"""Enable or disable autopilot mode"""
|
||||
state = self.load_state()
|
||||
state["autopilot"] = enabled
|
||||
self.save_state(state)
|
||||
logger.info(f"Autopilot {'enabled' if enabled else 'disabled'}")
|
||||
|
||||
def is_autopilot_enabled(self) -> bool:
|
||||
"""Check if autopilot mode is enabled"""
|
||||
return self.load_state().get("autopilot", False)
|
||||
|
||||
def set_logged_in(self, status: bool):
|
||||
"""Set the logged_in status"""
|
||||
self.logged_in = status
|
||||
logger.info(f"Logged in status set to: {status}")
|
||||
|
||||
def is_logged_in(self) -> bool:
|
||||
"""Check the logged_in status"""
|
||||
return self.logged_in
|
||||
Loading…
Add table
Add a link
Reference in a new issue