diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-23 17:37:40 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-08-23 17:37:40 +0200 |
| commit | 354ac11bd61ecbb587d101a68e2fdd08b1b1d15d (patch) | |
| tree | 2775eb4c8a079aaa728ec0826a9c4a8111e5df0e /wrappers/python/src | |
| parent | 784f7b281c2322a4145c546879a92adcc09ca99b (diff) | |
Python formatting: Run black
Diffstat (limited to 'wrappers/python/src')
| -rw-r--r-- | wrappers/python/src/__init__.py | 11 | ||||
| -rw-r--r-- | wrappers/python/src/main.py | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/wrappers/python/src/__init__.py b/wrappers/python/src/__init__.py index 74a529d..eba497c 100644 --- a/wrappers/python/src/__init__.py +++ b/wrappers/python/src/__init__.py @@ -35,10 +35,12 @@ try: except: lib = cdll.LoadLibrary(str(pathlib.Path(__file__).parent / "lib" / _libfile)) + class ErrorLevel(Enum): ERR_OTHER = 0 ERR_INFO = 1 + class DataError(Structure): _fields_ = [("data", c_void_p), ("error", c_void_p)] @@ -77,7 +79,9 @@ lib.GetDiscoServers.argtypes, lib.GetDiscoServers.restype = [c_char_p], DataErro lib.GoBack.argtypes, lib.GoBack.restype = [c_char_p], None lib.CancelOAuth.argtypes, lib.CancelOAuth.restype = [c_char_p], c_void_p lib.SetProfileID.argtypes, lib.SetProfileID.restype = [c_char_p, c_char_p], c_void_p -lib.ChangeSecureLocation.argtypes, lib.ChangeSecureLocation.restype = [c_char_p], c_void_p +lib.ChangeSecureLocation.argtypes, lib.ChangeSecureLocation.restype = [ + c_char_p +], c_void_p lib.SetSecureLocation.argtypes, lib.SetSecureLocation.restype = [ c_char_p, c_char_p, @@ -120,6 +124,7 @@ def get_ptr_string(ptr: c_void_p) -> str: return string.decode() return "" + def get_ptr_error(ptr: c_void_p) -> Optional[WrappedError]: error_string = get_ptr_string(ptr) @@ -136,20 +141,24 @@ def get_ptr_error(ptr: c_void_p) -> Optional[WrappedError]: cause = error_json["cause"] return WrappedError(traceback, cause, ErrorLevel(level)) + def get_error(ptr: c_void_p) -> str: error = get_ptr_error(ptr) if not error: return "" return error.traceback + def get_data_error(data_error: DataError) -> Tuple[str, str]: data = get_ptr_string(data_error.data) error = get_error(data_error.error) return data, error + def get_bool(boolInt: c_int) -> bool: return boolInt == 1 + decode_map = { c_int: get_bool, c_void_p: get_error, diff --git a/wrappers/python/src/main.py b/wrappers/python/src/main.py index e70d431..7ebeae6 100644 --- a/wrappers/python/src/main.py +++ b/wrappers/python/src/main.py @@ -112,7 +112,6 @@ class EduVPN(object): if config_err: raise Exception(config_err) - config_json_dict = json.loads(config_json) config = config_json_dict["config"] config_type = config_json_dict["config_type"] |
