100 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/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) |