summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wrappers/python/Makefile4
-rw-r--r--wrappers/python/discovery.py12
-rwxr-xr-x[-rw-r--r--]wrappers/python/test_discovery.py0
3 files changed, 10 insertions, 6 deletions
diff --git a/wrappers/python/Makefile b/wrappers/python/Makefile
index 53d1375..162b043 100644
--- a/wrappers/python/Makefile
+++ b/wrappers/python/Makefile
@@ -1,7 +1,7 @@
.PHONY: compile test
compile:
- ./discovery.py
+ python3 -m discovery
test:
- ./test_discovery.py
+ python3 -m unittest test_discovery
diff --git a/wrappers/python/discovery.py b/wrappers/python/discovery.py
index 2a9dcbe..21118a9 100644
--- a/wrappers/python/discovery.py
+++ b/wrappers/python/discovery.py
@@ -1,9 +1,13 @@
-#!/usr/bin/env python3
-
import platform
from ctypes import *
from enum import Enum
+_lib_suffixes = {
+ "windows": ".dll",
+ "linux": ".so",
+ "darwin": ".dylib",
+}
+
_arch = platform.machine().lower()
_arch = \
{
@@ -22,7 +26,7 @@ _arch = \
_os = platform.system().lower()
-_lib = cdll.LoadLibrary(f"../../exports/{_os}/{_arch}/eduvpn_verify")
+_lib = cdll.LoadLibrary(f"../../exports/{_os}/{_arch}/eduvpn_verify{_lib_suffixes[_os]}")
class GoSlice(Structure):
@@ -62,7 +66,7 @@ class VerifyError(Exception):
VerifyErrorCode.ErrUnknownExpectedFileName: "unknown expected file name",
VerifyErrorCode.ErrInvalidSignature: "invalid signature",
VerifyErrorCode.ErrInvalidSignatureUnknownKey: "invalid signature (unknown key)",
- VerifyErrorCode.ErrTooOld: "replay of previous signature (rollback)"
+ VerifyErrorCode.ErrTooOld: "replay of previous signature (rollback)",
}[self.code] if self.code != VerifyErrorCode.Unknown else f"unknown verify error ({self.code_int})"
diff --git a/wrappers/python/test_discovery.py b/wrappers/python/test_discovery.py
index 74fd601..74fd601 100644..100755
--- a/wrappers/python/test_discovery.py
+++ b/wrappers/python/test_discovery.py