#!/usr/bin/env python3 """ Setup script to ensure all required assets and directories are in place. Run this after cloning the repository or if assets are missing. """ import shutil from pathlib import Path import sys def setup_assets(): """Ensure all required assets and directories are properly configured.""" print("šŸ”§ Setting up Turmli Bar Calendar Tool assets...") # Create static directory if it doesn't exist static_dir = Path("static") if not static_dir.exists(): static_dir.mkdir(exist_ok=True) print("āœ… Created static directory") else: print("āœ… Static directory already exists") # Check for logo files logo_files = [ "Vektor-Logo.svg", "Vector-Logo.svg", # Alternative spelling "logo.svg" ] logo_found = False for logo_name in logo_files: logo_source = Path(logo_name) if logo_source.exists(): logo_dest = static_dir / "logo.svg" if not logo_dest.exists(): shutil.copy2(logo_source, logo_dest) print(f"āœ… Copied {logo_name} to static/logo.svg") else: print(f"āœ… Logo already exists in static directory") logo_found = True break if not logo_found: print("āš ļø Warning: No logo file found. The application will work but won't display a logo.") print(" To add a logo, place one of the following files in the project root:") print(" - Vektor-Logo.svg") print(" - Vector-Logo.svg") print(" - logo.svg") # Create cache directory structure cache_dir = Path(".cache") if not cache_dir.exists(): cache_dir.mkdir(exist_ok=True) print("āœ… Created cache directory") # Check for required Python version if sys.version_info < (3, 13): print(f"āš ļø Warning: Python {sys.version_info.major}.{sys.version_info.minor} detected.") print(" This application requires Python 3.13 or higher for optimal performance.") else: print(f"āœ… Python {sys.version_info.major}.{sys.version_info.minor} is compatible") # Check for UV installation uv_installed = shutil.which("uv") is not None if uv_installed: print("āœ… UV package manager is installed") else: print("āš ļø Warning: UV package manager not found.") print(" Install UV from: https://github.com/astral-sh/uv") print(" Or use pip with: pip install -r requirements.txt") # Create .env file from template if it doesn't exist env_file = Path(".env") env_example = Path(".env.example") if not env_file.exists() and env_example.exists(): shutil.copy2(env_example, env_file) print("āœ… Created .env file from template") print(" Please edit .env to configure your settings") elif env_file.exists(): print("āœ… .env file already exists") print("\nšŸŽ‰ Setup complete!") print("\nTo start the server, run:") if uv_installed: print(" ./run.sh") print(" or") print(" make run") else: print(" python main.py") print("\nThen open your browser to: http://localhost:8000") if __name__ == "__main__": try: setup_assets() except Exception as e: print(f"āŒ Error during setup: {e}") sys.exit(1)