70 lines
2.1 KiB
Python
Executable File
70 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Check for required system dependencies for the Hotel Booking platform.
|
|
"""
|
|
import subprocess
|
|
import shutil
|
|
import sys
|
|
import platform
|
|
|
|
def check_command(command, name, install_instructions):
|
|
"""Check if a command is available."""
|
|
if shutil.which(command):
|
|
version_output = subprocess.run(
|
|
[command, '--version'],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=5
|
|
)
|
|
version = version_output.stdout.split('\n')[0] if version_output.returncode == 0 else 'installed'
|
|
print(f"✓ {name}: {version}")
|
|
return True
|
|
else:
|
|
print(f"✗ {name}: NOT FOUND")
|
|
print(f" Installation: {install_instructions}")
|
|
return False
|
|
|
|
def main():
|
|
"""Check all dependencies."""
|
|
print("=" * 60)
|
|
print("Checking System Dependencies")
|
|
print("=" * 60)
|
|
print()
|
|
|
|
all_ok = True
|
|
|
|
# Check mysqldump
|
|
os_type = platform.system().lower()
|
|
if os_type == 'linux':
|
|
distro = platform.linux_distribution()[0].lower() if hasattr(platform, 'linux_distribution') else 'unknown'
|
|
if 'ubuntu' in distro or 'debian' in distro:
|
|
install_cmd = "sudo apt-get install mysql-client"
|
|
elif 'centos' in distro or 'rhel' in distro or 'fedora' in distro:
|
|
install_cmd = "sudo yum install mysql (or sudo dnf install mysql)"
|
|
else:
|
|
install_cmd = "Install MySQL client tools for your distribution"
|
|
elif os_type == 'darwin':
|
|
install_cmd = "brew install mysql-client"
|
|
else:
|
|
install_cmd = "Install MySQL client tools for your OS"
|
|
|
|
if not check_command('mysqldump', 'mysqldump (MySQL client)', install_cmd):
|
|
all_ok = False
|
|
|
|
print()
|
|
print("=" * 60)
|
|
|
|
if all_ok:
|
|
print("✓ All dependencies are installed!")
|
|
return 0
|
|
else:
|
|
print("✗ Some dependencies are missing.")
|
|
print()
|
|
print("You can install mysqldump using the provided script:")
|
|
print(" bash scripts/install_mysqldump.sh")
|
|
return 1
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|
|
|