Spaces:
Runtime error
Runtime error
Download docs/dev/verify_deployment.py from Atomio/hikvision-isup: direct link, hf CLI and curl.
- Browser
- Download file 5.39 kB
-
https://huggingface.co/spaces/Atomio/hikvision-isup/resolve/main/docs/dev/verify_deployment.py
- Command line
-
hf download hf://spaces/Atomio/hikvision-isup/docs/dev/verify_deployment.py
-
curl -L -o verify_deployment.py https://huggingface.co/spaces/Atomio/hikvision-isup/resolve/main/docs/dev/verify_deployment.py
5.39 kB
| #!/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) | |