From e361ec863961982e01f3d7f5842245dac88a05fd Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Wed, 12 Apr 2023 22:48:02 +0200 Subject: Format: Run gofumpt (Go) + black (py) --- internal/failover/ping_default.go | 3 ++- internal/failover/ping_windows.go | 3 ++- selenium_eduvpn.py | 8 ++++---- wrappers/python/docs/source/conf.py | 9 ++++----- wrappers/python/eduvpn_common/types.py | 20 ++++++++++++-------- wrappers/python/setup.py | 16 ++++++++++++---- wrappers/python/tests.py | 2 ++ 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/internal/failover/ping_default.go b/internal/failover/ping_default.go index 961c6db..ef56d5e 100644 --- a/internal/failover/ping_default.go +++ b/internal/failover/ping_default.go @@ -17,5 +17,6 @@ func NewPinger(gateway string, size int) (*Pinger, error) { return &Pinger{ listener: l, buffer: make([]byte, size-mtuOverhead), - gateway: &net.UDPAddr{IP: net.ParseIP(gateway)}}, nil + gateway: &net.UDPAddr{IP: net.ParseIP(gateway)}, + }, nil } diff --git a/internal/failover/ping_windows.go b/internal/failover/ping_windows.go index 2a39003..0de1cdf 100644 --- a/internal/failover/ping_windows.go +++ b/internal/failover/ping_windows.go @@ -15,5 +15,6 @@ func NewPinger(gateway string, size int) (*Pinger, error) { return &Pinger{ listener: l, buffer: make([]byte, size-mtuOverhead), - gateway: &net.IPAddr{IP: net.ParseIP(gateway)}}, nil + gateway: &net.IPAddr{IP: net.ParseIP(gateway)}, + }, nil } diff --git a/selenium_eduvpn.py b/selenium_eduvpn.py index b3a7c5f..2f452a0 100644 --- a/selenium_eduvpn.py +++ b/selenium_eduvpn.py @@ -46,15 +46,15 @@ def login_oauth(driver, authURL): elem.send_keys(portal_pass) # Click login button - driver.find_element("css selector", - ".frm > fieldset:nth-child(2) > button:nth-child(2)" + driver.find_element( + "css selector", ".frm > fieldset:nth-child(2) > button:nth-child(2)" ).click() # Check that we have reached the approve application page assert "VPN Portal - Approve Application" in driver.title # Click approve - driver.find_element("css selector", - ".frm > fieldset:nth-child(1) > button:nth-child(1)" + driver.find_element( + "css selector", ".frm > fieldset:nth-child(1) > button:nth-child(1)" ).click() diff --git a/wrappers/python/docs/source/conf.py b/wrappers/python/docs/source/conf.py index 52cf3b3..57638c5 100644 --- a/wrappers/python/docs/source/conf.py +++ b/wrappers/python/docs/source/conf.py @@ -16,17 +16,16 @@ release = '1.1.2' # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ - 'sphinx.ext.autodoc', - 'sphinx_rtd_theme', + "sphinx.ext.autodoc", + "sphinx_rtd_theme", ] -templates_path = ['_templates'] +templates_path = ["_templates"] exclude_patterns = [] - # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" html_static_path = [] diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py index b01455d..1eba468 100644 --- a/wrappers/python/eduvpn_common/types.py +++ b/wrappers/python/eduvpn_common/types.py @@ -1,5 +1,13 @@ -from ctypes import (CDLL, CFUNCTYPE, Structure, c_char_p, c_int, c_ulonglong, - c_void_p, cast) +from ctypes import ( + CDLL, + CFUNCTYPE, + Structure, + c_char_p, + c_int, + c_ulonglong, + c_void_p, + cast, +) from typing import Any, Iterator, List, Tuple @@ -86,9 +94,7 @@ def get_ptr_string(lib: CDLL, ptr: c_void_p) -> str: return "" -def get_data_error( - lib: CDLL, data_error: DataError -) -> Tuple[str, str]: +def get_data_error(lib: CDLL, data_error: DataError) -> Tuple[str, str]: """Convert a C data+error structure to a Python usable data+error structure :param lib: CDLL: The Go shared library @@ -104,9 +110,7 @@ def get_data_error( return data, error -def get_bool_error( - lib: CDLL, bool_error: BoolError -) -> Tuple[bool, str]: +def get_bool_error(lib: CDLL, bool_error: BoolError) -> Tuple[bool, str]: """Convert a C boolean (c int)+error structure to a Python usable boolean+error structure :param lib: CDLL: The Go shared library diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 1bc565a..8637032 100755 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -12,6 +12,7 @@ from wheel.bdist_wheel import bdist_wheel as _bdist_wheel _libname = "eduvpn_common" __version__ = "1.1.2" + def getlibpath(plat_name: str) -> typing.Union[str, None]: """Get library path for plat_name relative to exports/lib/ folder.""" @@ -65,8 +66,15 @@ def getlibpath(plat_name: str) -> typing.Union[str, None]: processed_os = os_map[plat_os] return ( - processed_os + "/" + arch_map[plat_arch] + "/" + - lib_prefixes[processed_os] + _libname + "-" + __version__ + lib_suffixes[processed_os] + processed_os + + "/" + + arch_map[plat_arch] + + "/" + + lib_prefixes[processed_os] + + _libname + + "-" + + __version__ + + lib_suffixes[processed_os] ) @@ -91,7 +99,7 @@ class bdist_wheel(_bdist_wheel): print("Unknown platform:", self.plat_name) sys.exit(1) - print("Building wheel for platform:",self.plat_name) + print("Building wheel for platform:", self.plat_name) # setuptools will only use paths inside the package for package_data, so we copy the library p = "eduvpn_common/lib" @@ -100,7 +108,7 @@ class bdist_wheel(_bdist_wheel): os.makedirs(p) shutil.copyfile(self.exports_lib_path + "/" + libpath, p+"/"+libpath.split("/")[-1]) _bdist_wheel.run(self) - shutil.rmtree("eduvpn_common/lib/") + shutil.rmtree(p) setup( diff --git a/wrappers/python/tests.py b/wrappers/python/tests.py index f2b01bd..5b36dfe 100644 --- a/wrappers/python/tests.py +++ b/wrappers/python/tests.py @@ -12,11 +12,13 @@ sys.path.append( from selenium_eduvpn import login_eduvpn + def handler(_old_state, new_state, data): if new_state == 6: login_eduvpn(data) return True + class ConfigTests(unittest.TestCase): def testConfig(self): _eduvpn = eduvpn.EduVPN("org.letsconnect-vpn.app.linux", "0.1.0", "testconfigs") -- cgit v1.2.3