summaryrefslogtreecommitdiff
path: root/wrappers/python
diff options
context:
space:
mode:
Diffstat (limited to 'wrappers/python')
-rw-r--r--wrappers/python/main.py5
-rwxr-xr-xwrappers/python/setup.py74
-rw-r--r--wrappers/python/src/main.py4
-rw-r--r--wrappers/python/tests.py7
4 files changed, 59 insertions, 31 deletions
diff --git a/wrappers/python/main.py b/wrappers/python/main.py
index c887fed..a94281a 100644
--- a/wrappers/python/main.py
+++ b/wrappers/python/main.py
@@ -21,6 +21,7 @@ def ask_profile_input(total: int) -> int:
# The profile is one based, move to zero based input
return profile_index - 1
+
# Sets up the callbacks using the provided class
def setup_callbacks(_eduvpn: eduvpn.EduVPN) -> None:
# The callback that starst OAuth
@@ -33,7 +34,9 @@ def setup_callbacks(_eduvpn: eduvpn.EduVPN) -> None:
# The callback which asks the user for a profile
@_eduvpn.event.on("Ask_Profile", eduvpn.StateType.Enter)
def ask_profile(old_state: str, profiles: str):
- print("Multiple profiles found, you need to select a profile, old state: {old_state}")
+ print(
+ "Multiple profiles found, you need to select a profile, old state: {old_state}"
+ )
# Parse the profiles as JSON
data = json.loads(profiles)
diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py
index 533ba82..2b682cd 100755
--- a/wrappers/python/setup.py
+++ b/wrappers/python/setup.py
@@ -15,47 +15,65 @@ _libname = "eduvpn_common"
def getlibpath(plat_name: str) -> typing.Union[str, None]:
"""Get library path for plat_name relative to exports/lib/ folder."""
- _plat_map = defaultdict(lambda: plat_name, {
- "win32": "win-x86",
- })
+ _plat_map = defaultdict(
+ lambda: plat_name,
+ {
+ "win32": "win-x86",
+ },
+ )
plat_split = _plat_map[plat_name].split("-", 1)
if len(plat_split) != 2:
return None
plat_os, plat_arch = plat_split
- _os_map = defaultdict(lambda: plat_os, {
- "win": "windows",
- })
- _lib_prefixes = defaultdict(lambda: "lib", {
- "windows": "",
- })
- _lib_suffixes = defaultdict(lambda: ".so", {
- "windows": ".dll",
- "darwin": ".dylib",
- })
- _arch_map = defaultdict(lambda: plat_arch, {
- "aarch64_be": "arm64",
- "aarch64": "arm64",
- "armv8b": "arm64",
- "armv8l": "arm64",
- "x86": "386",
- "x86pc": "386",
- "i86pc": "386",
- "i386": "386",
- "i686": "386",
- "x86_64": "amd64",
- "i686-64": "amd64",
- })
+ _os_map = defaultdict(
+ lambda: plat_os,
+ {
+ "win": "windows",
+ },
+ )
+ _lib_prefixes = defaultdict(
+ lambda: "lib",
+ {
+ "windows": "",
+ },
+ )
+ _lib_suffixes = defaultdict(
+ lambda: ".so",
+ {
+ "windows": ".dll",
+ "darwin": ".dylib",
+ },
+ )
+ _arch_map = defaultdict(
+ lambda: plat_arch,
+ {
+ "aarch64_be": "arm64",
+ "aarch64": "arm64",
+ "armv8b": "arm64",
+ "armv8l": "arm64",
+ "x86": "386",
+ "x86pc": "386",
+ "i86pc": "386",
+ "i386": "386",
+ "i686": "386",
+ "x86_64": "amd64",
+ "i686-64": "amd64",
+ },
+ )
processed_os = _os_map[plat_os]
- return f"{processed_os}/{_arch_map[plat_arch]}/" \
- f"{_lib_prefixes[processed_os]}{_libname}{_lib_suffixes[processed_os]}"
+ return (
+ f"{processed_os}/{_arch_map[plat_arch]}/"
+ f"{_lib_prefixes[processed_os]}{_libname}{_lib_suffixes[processed_os]}"
+ )
# Adapted from https://stackoverflow.com/a/51794740
# You would say there would be a better way to do all of this, but I couldn't find it
+
class bdist_wheel(_bdist_wheel):
user_options = _bdist_wheel.user_options + [
("exports-lib-path=", None, "path to exports/lib directory"),
diff --git a/wrappers/python/src/main.py b/wrappers/python/src/main.py
index dd8f36a..47e2893 100644
--- a/wrappers/python/src/main.py
+++ b/wrappers/python/src/main.py
@@ -22,7 +22,9 @@ class EventHandler(object):
return wrapped_f
- def run_state(self, state: str, other_state: str, state_type: StateType, data: str) -> None:
+ def run_state(
+ self, state: str, other_state: str, state_type: StateType, data: str
+ ) -> None:
if (state, state_type) not in self.handlers:
return
for func in self.handlers[(state, state_type)]:
diff --git a/wrappers/python/tests.py b/wrappers/python/tests.py
index 60ed79e..7f17ef6 100644
--- a/wrappers/python/tests.py
+++ b/wrappers/python/tests.py
@@ -7,15 +7,19 @@ import sys
import os
# Import project root directory where the selenium python utility is
-sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
+sys.path.append(
+ os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+)
from selenium_eduvpn import login_eduvpn
+
class ConfigTests(unittest.TestCase):
def testConfig(self):
_eduvpn = eduvpn.EduVPN("org.eduvpn.app.linux", "testconfigs")
# This can throw an exception
_eduvpn.register()
+
@_eduvpn.event.on("OAuth_Started", eduvpn.StateType.Enter)
def oauth_initialized(old_state, url):
login_eduvpn(url)
@@ -41,5 +45,6 @@ class ConfigTests(unittest.TestCase):
return
self.fail("No exception thrown on second register")
+
if __name__ == "__main__":
unittest.main()