""" Read configuration directly from GeViServer using SDK """ import sys import os sys.path.insert(0, r'C:\GEVISOFT') # Try to load the SDK DLL import clr clr.AddReference('GeViProcAPINET_4_0') from GeViProcAPI import GeViSetupClient def main(): print("Connecting to GeViServer...") # Create setup client setup_client = GeViSetupClient() # Connect to local server result = setup_client.ConnectRemote("localhost", "sysadmin", "", "") if result != 0: print(f"ERROR: Failed to connect. Result code: {result}") return print("Connected successfully!") # Read configuration print("Reading configuration...") config_data = setup_client.ReadSetup() if config_data is None or len(config_data) == 0: print("ERROR: Failed to read configuration") return print(f"Read {len(config_data)} bytes") # Save to file with open('C:\\DEV\\COPILOT\\current_config.set', 'wb') as f: f.write(bytes(config_data)) print("Saved to: C:\\DEV\\COPILOT\\current_config.set") setup_client.Disconnect() if __name__ == '__main__': main()