#!/usr/bin/env python3 """Simple script to check G-Core server configuration without Unicode""" 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("=" * 70) print("G-Core Servers Configuration (GeViSoft -> GeViScope connections)") print("=" * 70) print() if not gcore_servers: print("WARNING: NO G-CORE SERVERS CONFIGURED!") print() print("This means GeViSoft is NOT connected to any GeViScope servers.") print("Cameras are on GeViScope servers, so you won't see any cameras.") print() print("To fix: Add a G-Core server pointing to your GeViScope:") print(' POST /api/v1/configuration/servers') print(' {') print(' "alias": "Local GeViScope",') print(' "host": "localhost",') print(' "user": "gevisoft",') print(' "password": "your_password",') print(' "enabled": true') print(' }') else: print(f"Found {len(gcore_servers)} G-Core server(s):") print() 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) has_enabled_localhost = any(s['host'] in ['localhost', '127.0.0.1'] and s['enabled'] for s in gcore_servers) if not has_localhost: print() print("WARNING: No G-Core server pointing to 'localhost'!") print("You have GSCServer.exe running locally but GeViSoft isn't configured to connect to it.") print() print("To connect to your local GeViScope, add a server with host='localhost'") elif has_localhost and not has_enabled_localhost: print() print("WARNING: G-Core server for 'localhost' exists but is DISABLED!") print("Enable it to see cameras from your local GeViScope.") else: print() print("OK: GeViSoft is configured to connect to local GeViScope (localhost)") print() print("If cameras list is still empty, check:") print(" 1. Is GSCServer.exe actually running? (check with Task Manager)") print(" 2. Are cameras configured in the local GeViScope?") print(" 3. Check GeViServer logs for connection errors") print(" 4. Check credentials are correct") await channel.close() except Exception as e: print() print(f"ERROR: {e}") print() print("Make sure:") print(" 1. SDK Bridge is running (port 50051)") print(" 2. GeViServer is running") print(" 3. Run: .\\status-services.ps1") if __name__ == "__main__": asyncio.run(check_servers())