""" Download configuration using SetupClient """ import sys sys.path.insert(0, r'C:\DEV\COPILOT\geutebruck-api\src\api\protos') import asyncio import grpc import configuration_pb2 import configuration_pb2_grpc async def download_config(): """Download configuration file using SetupClient""" channel = grpc.aio.insecure_channel('localhost:50051') stub = configuration_pb2_grpc.ConfigurationServiceStub(channel) try: print("Downloading configuration from GeViServer...") request = configuration_pb2.DownloadConfigurationRequest() response = await stub.DownloadConfiguration(request, timeout=30.0) if response.success: print(f"[OK] Configuration downloaded successfully") print(f" File size: {len(response.config_data)} bytes") print(f" Saved to: C:\\GEVISOFT\\GeViScopeSetup.set") # Save to file with open(r"C:\GEVISOFT\GeViScopeSetup.set", "wb") as f: f.write(response.config_data) return True else: print(f"[ERROR] Download failed: {response.message}") return False except grpc.RpcError as e: print(f"[ERROR] gRPC error: {e.code()} - {e.details()}") return False finally: await channel.close() if __name__ == "__main__": result = asyncio.run(download_config()) sys.exit(0 if result else 1)