mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-01 03:31:25 +02:00
Manually configure AMS slots for third-party or generic filaments: 1. Hover over an AMS slot on the printer card 2. Click the menu button (:material-dots-vertical:) that appears 3. Select **Configure Slot** 4. Choose a filament preset from your Bambu Studio cloud presets 5. Select a matching K profile (pressure advance calibration) 6. Optionally set a custom color using the color picker 7. Click **Configure Slot** to apply **Color Picker Features:** - Enter custom hex codes or color names (e.g., "brown", "FF8800") - Live preview of selected color - Expandable color picker in Configure AMS Slot modal: - 8 basic colors shown by default - 24 additional colors available via expand button - Tests for ConfigureAmsSlotModal component - Tests for AMS change callback - Updated README with AMS slot configuration feature - Wiki documentation for Configure AMS Slot feature - Multi plate issue where plate names showed incorrect. #93 - Items from Queue end up as "source" files in archive. #107 - Added env variable support to change network port. #108 Docs -> https://wiki.bambuddy.cool/getting-started/docker/?h=port#custom-port
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
import logging
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
# Application version - single source of truth
|
|
APP_VERSION = "0.1.6b10"
|
|
GITHUB_REPO = "maziggy/bambuddy"
|
|
|
|
# App directory - where the application is installed (for static files)
|
|
_app_dir = Path(__file__).resolve().parent.parent.parent.parent
|
|
|
|
# Data directory - for persistent data (database, archives)
|
|
# Use DATA_DIR env var if set (Docker), otherwise use project root (local dev)
|
|
_data_dir_env = os.environ.get("DATA_DIR")
|
|
_data_dir = Path(_data_dir_env) if _data_dir_env else _app_dir
|
|
|
|
# Log directory - use LOG_DIR env var if set, otherwise use app_dir/logs
|
|
_log_dir_env = os.environ.get("LOG_DIR")
|
|
_log_dir = Path(_log_dir_env) if _log_dir_env else _app_dir / "logs"
|
|
|
|
|
|
def _migrate_database() -> Path:
|
|
"""Migrate database from old name to new name if needed."""
|
|
old_db = _data_dir / "bambutrack.db"
|
|
new_db = _data_dir / "bambuddy.db"
|
|
|
|
# If old database exists and new one doesn't, rename it
|
|
if old_db.exists() and not new_db.exists():
|
|
try:
|
|
old_db.rename(new_db)
|
|
logging.info(f"Migrated database: {old_db} -> {new_db}")
|
|
except Exception as e:
|
|
logging.warning(f"Could not migrate database: {e}. Using old location.")
|
|
return old_db
|
|
|
|
# If old database exists (and new one now exists too), it was migrated
|
|
# If only new exists, use new
|
|
# If neither exists, use new (will be created)
|
|
return new_db if new_db.exists() or not old_db.exists() else old_db
|
|
|
|
|
|
# Determine database path (handles migration)
|
|
_db_path = _migrate_database()
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
app_name: str = "Bambuddy"
|
|
debug: bool = False # Default to production mode
|
|
|
|
# Paths
|
|
base_dir: Path = _data_dir # For backwards compatibility
|
|
archive_dir: Path = _data_dir / "archive"
|
|
static_dir: Path = _app_dir / "static" # Static files are part of app, not data
|
|
log_dir: Path = _log_dir
|
|
database_url: str = f"sqlite+aiosqlite:///{_db_path}"
|
|
|
|
# Logging
|
|
log_level: str = "INFO" # Override with LOG_LEVEL env var or DEBUG=true
|
|
log_to_file: bool = True # Set to false to disable file logging
|
|
|
|
# API
|
|
api_prefix: str = "/api/v1"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|
|
|
|
|
|
settings = Settings()
|
|
|
|
# Ensure directories exist
|
|
settings.archive_dir.mkdir(exist_ok=True)
|
|
settings.static_dir.mkdir(exist_ok=True)
|
|
if settings.log_to_file:
|
|
settings.log_dir.mkdir(exist_ok=True)
|