diff options
Diffstat (limited to 'wrappers/python/eduvpn_common/loader.py')
| -rw-r--r-- | wrappers/python/eduvpn_common/loader.py | 135 |
1 files changed, 82 insertions, 53 deletions
diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index ca0fd20..360ec04 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -1,13 +1,12 @@ import pathlib -from collections import defaultdict from ctypes import CDLL, c_char_p, c_int, c_void_p, cdll from eduvpn_common import __version__ from eduvpn_common.types import ( BoolError, + DataError, ProxyReady, ProxySetup, - DataError, ReadRxBytes, TokenGetter, TokenSetter, @@ -31,7 +30,7 @@ def load_lib() -> CDLL: try: lib = cdll.LoadLibrary(libfile) # Otherwise, library should have been copied to the lib/ folder - except: + except Exception: lib = cdll.LoadLibrary(str(pathlib.Path(__file__).parent / "lib" / libfile)) return lib @@ -52,64 +51,94 @@ def initialize_functions(lib: CDLL) -> None: lib.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None lib.DiscoOrganizations.argtypes, lib.DiscoOrganizations.restype = [c_int], DataError lib.DiscoServers.argtypes, lib.DiscoServers.restype = [c_int], DataError - lib.GetConfig.argtypes, lib.GetConfig.restype = [ - c_int, - c_int, - c_char_p, - c_int, - c_int, - ], DataError - lib.AddServer.argtypes, lib.AddServer.restype = [ - c_int, - c_int, + lib.GetConfig.argtypes, lib.GetConfig.restype = ( + [ + c_int, + c_int, + c_char_p, + c_int, + c_int, + ], + DataError, + ) + lib.AddServer.argtypes, lib.AddServer.restype = ( + [ + c_int, + c_int, + c_char_p, + c_int, + ], c_char_p, - c_int, - ], c_char_p + ) lib.CurrentServer.argtypes, lib.CurrentServer.restype = [], DataError - lib.RemoveServer.argtypes, lib.RemoveServer.restype = [ - c_int, + lib.RemoveServer.argtypes, lib.RemoveServer.restype = ( + [ + c_int, + c_char_p, + ], c_char_p, - ], c_char_p + ) lib.ServerList.argtypes, lib.ServerList.restype = [], DataError - lib.Register.argtypes, lib.Register.restype = [ - c_char_p, - c_char_p, - c_char_p, - VPNStateChange, - c_int, - ], c_void_p + lib.Register.argtypes, lib.Register.restype = ( + [ + c_char_p, + c_char_p, + c_char_p, + VPNStateChange, + c_int, + ], + c_void_p, + ) lib.RenewSession.argtypes, lib.RenewSession.restype = [c_int], c_void_p - lib.SetTokenHandler.argtypes, lib.SetTokenHandler.restype = [ - TokenGetter, - TokenSetter, - ], c_void_p + lib.SetTokenHandler.argtypes, lib.SetTokenHandler.restype = ( + [ + TokenGetter, + TokenSetter, + ], + c_void_p, + ) lib.Cleanup.argtypes, lib.Cleanup.restype = [c_int], c_void_p lib.SetProfileID.argtypes, lib.SetProfileID.restype = [c_char_p], c_void_p lib.CookieNew.argtypes, lib.CookieNew.restype = [], c_int lib.CookieReply.argtypes, lib.CookieReply.restype = [c_int, c_char_p], c_void_p lib.CookieCancel.argtypes, lib.CookieCancel.restype = [c_int], c_void_p lib.CookieDelete.argtypes, lib.CookieDelete.restype = [c_int], c_void_p - lib.SetSecureLocation.argtypes, lib.SetSecureLocation.restype = [ - c_char_p, - c_char_p, - ], c_void_p - lib.SetState.argtypes, lib.SetState.restype = [ - c_int, - ], c_void_p - lib.InState.argtypes, lib.InState.restype = [ - c_int, - ], BoolError - lib.StartFailover.argtypes, lib.StartFailover.restype = [ - c_int, - c_char_p, - c_int, - ReadRxBytes, - ], BoolError - lib.StartProxyguard.argtypes, lib.StartProxyguard.restype = [ - c_int, - c_char_p, - c_int, - c_char_p, - ProxySetup, - ProxyReady, - ], c_void_p + lib.SetSecureLocation.argtypes, lib.SetSecureLocation.restype = ( + [ + c_char_p, + c_char_p, + ], + c_void_p, + ) + lib.SetState.argtypes, lib.SetState.restype = ( + [ + c_int, + ], + c_void_p, + ) + lib.InState.argtypes, lib.InState.restype = ( + [ + c_int, + ], + BoolError, + ) + lib.StartFailover.argtypes, lib.StartFailover.restype = ( + [ + c_int, + c_char_p, + c_int, + ReadRxBytes, + ], + BoolError, + ) + lib.StartProxyguard.argtypes, lib.StartProxyguard.restype = ( + [ + c_int, + c_char_p, + c_int, + c_char_p, + ProxySetup, + ProxyReady, + ], + c_void_p, + ) |
