- Created .gitignore to exclude virtual environment, logs, and database files. - Updated README.md with project description, features, folder structure, requirements, and usage instructions. - Implemented versioning and developer ID in agentm/__init__.py. - Developed main application logic in agentm/app.py, including credential handling and screen navigation. - Added database initialization and ROM management logic in agentm/logic/db.py and agentm/logic/db_functions.py. - Integrated DIAMBRA login functionality in agentm/logic/diambra_login.py. - Created ROM verification and caching system in agentm/logic/roms.py. - Designed user interface components for home and login screens in agentm/views/home.py and agentm/views/login.py. - Added logging utility in agentm/utils/logger.py for better debugging and tracking. - Included assets such as game images, styles, and logos. - Updated requirements.txt with necessary dependencies for the project.
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
from textual.app import App
|
|
from agentm.views.home import HomeView
|
|
from agentm.views.login import LoginView
|
|
from agentm import DIAMBRA_CREDENTIALS_PATH
|
|
from agentm.utils.logger import log_with_caller
|
|
from agentm.logic.db import initialize_database
|
|
|
|
class AgentMApp(App):
|
|
CSS_PATH = "assets/styles.tcss"
|
|
|
|
def on_mount(self) -> None:
|
|
"""Called when the app starts."""
|
|
log_with_caller("debug", "App mounted. Initializing database...")
|
|
initialize_database()
|
|
|
|
log_with_caller("debug", "Checking for credentials...")
|
|
|
|
if DIAMBRA_CREDENTIALS_PATH.exists():
|
|
token = DIAMBRA_CREDENTIALS_PATH.read_text().strip()
|
|
|
|
if token and len(token) > 10:
|
|
log_with_caller("info", "Found populated DIAMBRA credentials. Launching Home.")
|
|
self.push_screen(HomeView())
|
|
return
|
|
else:
|
|
log_with_caller("warning", "Token file exists but appears empty or malformed.")
|
|
|
|
log_with_caller("info", "No valid credentials found. Launching Login screen.")
|
|
self.push_screen(LoginView())
|
|
|
|
async def on_login_view_login_success(self, message: LoginView.LoginSuccess) -> None:
|
|
"""Handle successful login event and switch to Home screen."""
|
|
log_with_caller("info", "Handling LoginSuccess event. Launching Home.")
|
|
self.push_screen(HomeView())
|