From 516a25eb926a8b9a879e4f38c86d4dbb9b9e0948 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Wed, 26 Oct 2022 17:09:52 +0200 Subject: Client + Exports + Python: Add a function for getting the current server --- wrappers/python/eduvpn_common/server.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'wrappers/python/eduvpn_common/server.py') diff --git a/wrappers/python/eduvpn_common/server.py b/wrappers/python/eduvpn_common/server.py index fc5711e..3a5ff69 100644 --- a/wrappers/python/eduvpn_common/server.py +++ b/wrappers/python/eduvpn_common/server.py @@ -245,9 +245,11 @@ def get_transition_server(lib: CDLL, ptr: c_void_p) -> Optional[Server]: :return: The server if there is any :rtype: Optional[Server] """ - server = get_server(cast(ptr, POINTER(cServer))) - lib.FreeServer(ptr) - return server + if ptr: + server = get_server(cast(ptr, POINTER(cServer))) + lib.FreeServer(ptr) + return server + return None def get_transition_profiles(lib: CDLL, ptr: c_void_p) -> Optional[Profiles]: @@ -261,9 +263,11 @@ def get_transition_profiles(lib: CDLL, ptr: c_void_p) -> Optional[Profiles]: :return: The profiles if there is any :rtype: Optional[Profiles] """ - profiles = get_profiles(cast(ptr, POINTER(cServerProfiles))) - lib.FreeProfiles(ptr) - return profiles + if ptr: + profiles = get_profiles(cast(ptr, POINTER(cServerProfiles))) + lib.FreeProfiles(ptr) + return profiles + return None def get_servers(lib: CDLL, ptr: c_void_p) -> Optional[List[Server]]: -- cgit v1.2.3