CoolFace
Apppublic

OnyxMunk/AudioForge

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes
verify_port_config.py59 linesDownload Raw Back to scripts
1#!/usr/bin/env python3
2"""Verify PostgreSQL port configuration is correct."""
3
4import re
5from pathlib import Path
6
7def check_file(file_path: Path, pattern: str, should_match: bool, description: str) -> tuple[bool, str]:
8    """Check if a file matches the expected pattern."""
9    try:
10        content = file_path.read_text(encoding='utf-8', errors='ignore')
11        matches = bool(re.search(pattern, content))
12        
13        if matches == should_match:
14            return True, f"✅ {description}"
15        else:
16            return False, f"❌ {description} - {'Found' if matches else 'Not found'} when {'should' if should_match else 'should not'} be present"
17    except FileNotFoundError:
18        return False, f"❌ {description} - File not found"
19    except Exception as e:
20        return False, f"❌ {description} - Error: {e}"
21
22def main():
23    """Verify port configuration."""
24    project_root = Path(__file__).parent.parent
25    
26    checks = [
27        # File, pattern, should_match, description
28        (project_root / "docker-compose.yml", r'"5433:5432"', True, "docker-compose.yml maps port 5433:5432"),
29        (project_root / "scripts" / "setup_env.py", r'localhost:5433.*audioforge', True, "setup_env.py uses port 5433 for development"),
30        (project_root / "backend" / "app" / "core" / "config.py", r'localhost:5433.*audioforge', True, "config.py defaults to port 5433"),
31        (project_root / "scripts" / "create_env_with_token.py", r'localhost:5433.*audioforge', True, "create_env_with_token.py uses port 5433"),
32    ]
33    
34    print("\n🔍 Verifying PostgreSQL Port Configuration\n")
35    print("=" * 60)
36    
37    all_passed = True
38    for file_path, pattern, should_match, description in checks:
39        passed, message = check_file(file_path, pattern, should_match, description)
40        print(message)
41        if not passed:
42            all_passed = False
43    
44    print("=" * 60)
45    
46    if all_passed:
47        print("\n✅ All port configurations are correct!")
48        print("\nThe fix ensures:")
49        print("  • Docker exposes PostgreSQL on port 5433")
50        print("  • Development setup scripts use port 5433")
51        print("  • Backend defaults to port 5433")
52        return 0
53    else:
54        print("\n❌ Some configurations need fixing!")
55        return 1
56
57if __name__ == "__main__":
58    exit(main())
59