#!/usr/bin/env python3 """ Deployment Verification Script Verifies that the ISUP 5.0 server is running correctly after deployment """ import requests import socket import time import sys from datetime import datetime def check_web_interface(base_url="http://localhost:7860"): """Check if web interface is accessible""" print("🌐 Checking web interface...") try: # Health check response = requests.get(f"{base_url}/api/health", timeout=10) if response.status_code == 200: health = response.json() print(f"✅ Health check: {health['status']}") print(f"✅ ISUP server: {health['isup_server']}") else: print(f"❌ Health check failed: {response.status_code}") return False # Protocol info response = requests.get(f"{base_url}/api/protocol/info", timeout=5) if response.status_code == 200: protocol = response.json() print(f"✅ Protocol: {protocol['protocol']} {protocol['version']}") print(f"✅ Binary protocol: {protocol['binary_protocol']}") else: print(f"❌ Protocol info failed: {response.status_code}") return False # Dashboard response = requests.get(base_url, timeout=5) if response.status_code == 200: print("✅ Dashboard accessible") else: print(f"❌ Dashboard failed: {response.status_code}") return False return True except requests.exceptions.ConnectionError: print("❌ Cannot connect to web interface") return False except Exception as e: print(f"❌ Web interface error: {e}") return False def check_isup_port(host="localhost", port=7660): """Check if ISUP TCP port is open""" print(f"📡 Checking ISUP port {host}:{port}...") try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(5) result = sock.connect_ex((host, port)) sock.close() if result == 0: print(f"✅ ISUP port {port} is open and accepting connections") return True else: print(f"❌ ISUP port {port} is not accessible") return False except Exception as e: print(f"❌ ISUP port check error: {e}") return False def check_docker_deployment(): """Check if running in Docker""" print("đŸŗ Checking Docker deployment...") try: # Check if we're in a container with open('/proc/1/cgroup', 'r') as f: content = f.read() if 'docker' in content or 'containerd' in content: print("✅ Running in Docker container") return True else: print("â„šī¸ Not running in Docker (local deployment)") return False except FileNotFoundError: print("â„šī¸ Cannot determine if running in Docker") return False except Exception as e: print(f"âš ī¸ Docker check error: {e}") return False def main(): """Main verification function""" print("🔍 ISUP 5.0 Deployment Verification") print("=" * 50) print(f"📅 Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") print() # Determine base URL base_url = "http://localhost:7860" if len(sys.argv) > 1: base_url = sys.argv[1] print(f"🌐 Using custom URL: {base_url}") # Check Docker deployment is_docker = check_docker_deployment() print() # Check web interface web_ok = check_web_interface(base_url) print() # Check ISUP port host = "localhost" if "hf.space" in base_url: # Extract hostname for HuggingFace Spaces host = base_url.replace("http://", "").replace("https://", "") isup_ok = check_isup_port(host, 7660) print() # Summary print("=" * 50) print("📋 DEPLOYMENT VERIFICATION SUMMARY") print("=" * 50) if web_ok and isup_ok: print("🎉 DEPLOYMENT SUCCESSFUL!") print("✅ Web interface is accessible") print("✅ ISUP 5.0 TCP server is running") print("✅ Ready for device connections") print() print("🔧 DEVICE CONFIGURATION:") print(f" Server Address: {host}") print(" Port: 7660") print(" Protocol: ISUP 5.0") print(" Device ID: 255") print(" EHome Key: hikvision123") print() print(f"🌐 Dashboard: {base_url}") if "hf.space" in base_url: print("🚀 HuggingFace Spaces deployment detected") print(" Your server is publicly accessible!") return True else: print("❌ DEPLOYMENT ISSUES DETECTED") if not web_ok: print("❌ Web interface not accessible") if not isup_ok: print("❌ ISUP TCP port not accessible") print() print("🔧 TROUBLESHOOTING:") print("1. Check if server is running") print("2. Verify port forwarding (7860, 7660)") print("3. Check firewall settings") print("4. Review server logs") return False if __name__ == "__main__": success = main() sys.exit(0 if success else 1)