#!/usr/bin/env python3 """Check G-Core server configuration to see if GeViSoft is connected to GeViScope""" import asyncio import sys import os # Add src/api to path sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src', 'api')) import grpc from protos import configuration_pb2, configuration_pb2_grpc async def check_servers(): """Check which G-Core servers are configured""" # Connect to SDK Bridge channel = grpc.aio.insecure_channel('localhost:50051') stub = configuration_pb2_grpc.ConfigurationServiceStub(channel) try: # Read configuration tree request = configuration_pb2.ReadConfigurationTreeRequest() response = await stub.ReadConfigurationTree(request, timeout=10.0) # Find GeViGCoreServer folder gcore_servers = [] for child in response.root.children: if child.name == "GeViGCoreServer": for server in child.children: if server.type == "folder": server_dict = {node.name: node for node in server.children} # Extract server details server_info = { 'id': server.name.split('_')[1] if '_' in server.name else server.name, 'alias': server_dict.get('Alias', {}).string_value if 'Alias' in server_dict else 'N/A', 'host': server_dict.get('Host', {}).string_value if 'Host' in server_dict else 'N/A', 'enabled': None, 'user': server_dict.get('User', {}).string_value if 'User' in server_dict else 'N/A' } # Check enabled (can be bool or int32) if 'Enabled' in server_dict: enabled_node = server_dict['Enabled'] if hasattr(enabled_node, 'bool_value'): server_info['enabled'] = enabled_node.bool_value elif hasattr(enabled_node, 'int_value'): server_info['enabled'] = bool(enabled_node.int_value) gcore_servers.append(server_info) print(f"\n{'='*70}") print(f"G-Core Servers Configuration (GeViSoft → GeViScope connections)") print(f"{'='*70}\n") if not gcore_servers: print("⚠️ NO G-CORE SERVERS CONFIGURED!") print("\nThis means GeViSoft is NOT connected to any GeViScope servers.") print("Cameras are on GeViScope servers, so you won't see any cameras.") print("\nTo fix: Add a G-Core server pointing to your GeViScope:") print(" POST /api/v1/configuration/servers") print(" {") print(' "alias": "Local GeViScope",') print(' "host": "localhost", # or IP of GSCServer') print(' "user": "gevisoft",') print(' "password": "your_password",') print(' "enabled": true') print(" }") else: print(f"Found {len(gcore_servers)} G-Core server(s):\n") for server in gcore_servers: status = "✅ ENABLED" if server['enabled'] else "❌ DISABLED" localhost_marker = " ← LOCAL GEVISCOPE!" if server['host'] in ['localhost', '127.0.0.1'] else "" print(f" [{server['id']}] {server['alias']}") print(f" Host: {server['host']}{localhost_marker}") print(f" User: {server['user']}") print(f" Status: {status}") print() # Check if localhost is in the list has_localhost = any(s['host'] in ['localhost', '127.0.0.1'] for s in gcore_servers) if not has_localhost: print(f"\n⚠️ WARNING: No G-Core server pointing to 'localhost'!") print(f" You have GSCServer.exe running locally but GeViSoft isn't configured to connect to it.") print(f"\n To connect to your local GeViScope, add a server with host='localhost'") else: print(f"\n✅ Good: GeViSoft is configured to connect to local GeViScope (localhost)") print(f"\n If cameras list is still empty, check:") print(f" 1. Is GSCServer.exe actually running? (check with Task Manager)") print(f" 2. Are cameras configured in the local GeViScope?") print(f" 3. Is the G-Core server connection enabled?") print(f" 4. Check GeViServer logs for connection errors") await channel.close() except Exception as e: print(f"\n❌ Error: {e}") print(f"\nMake sure:") print(f" 1. SDK Bridge is running (port 50051)") print(f" 2. GeViServer is running") print(f" 3. Run: .\\status-services.ps1") if __name__ == "__main__": asyncio.run(check_servers())