#!/usr/bin/env python3 """Simple script to check G-Core servers using proper imports""" import asyncio import sys import os # Add parent directory to path sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) # Import using package path from api.protos import configuration_pb2, configuration_pb2_grpc import grpc async def check_servers(): """Check G-Core server configuration""" channel = grpc.aio.insecure_channel('localhost:50051') stub = configuration_pb2_grpc.ConfigurationServiceStub(channel) try: print("Attempting to call ReadConfigurationTree...") request = configuration_pb2.ReadConfigurationTreeRequest() response = await stub.ReadConfigurationTree(request, timeout=10.0) print(f"Success! Got response with {len(response.root.children)} root children") # Find GeViGCoreServer folder for child in response.root.children: if child.name == "GeViGCoreServer": print(f"\nFound GeViGCoreServer folder with {len(child.children)} servers") for server in child.children: if server.type == "folder": # Extract basic info server_dict = {node.name: node for node in server.children} 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' print(f" - {server.name}: {alias} ({host})") break await channel.close() except Exception as e: print(f"ERROR: {type(e).__name__}: {e}") await channel.close() if __name__ == "__main__": asyncio.run(check_servers())