diff options
| -rw-r--r-- | docs/src/api/python/functions.md | 4 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/event.py | 6 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 4 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/state.py | 6 | ||||
| -rw-r--r-- | wrappers/python/main.py | 8 | ||||
| -rw-r--r-- | wrappers/python/tests.py | 2 |
6 files changed, 15 insertions, 15 deletions
diff --git a/docs/src/api/python/functions.md b/docs/src/api/python/functions.md index 060a72f..ecc4982 100644 --- a/docs/src/api/python/functions.md +++ b/docs/src/api/python/functions.md @@ -88,14 +88,14 @@ For this, the `eduvpn.EduVPN` class has the following syntax: # Where _eduvpn is the eduvpn.EduVPN class instance # This gets called when the New_State_Example state is entered # old_state is then the old state -@_eduvpn.event.on("New_State_Example", eduvpn.StateType.Enter) +@_eduvpn.event.on("New_State_Example", eduvpn.StateType.ENTER) def example_enter(old_state: str, data: str) ``` ```python # Where _eduvpn is the eduvpn.EduVPN class instance # This gets called when the Old_State_Example state is left # new_state is then the new state -@_eduvpn.event.on("Old_State_Example", eduvpn.StateType.Leave) +@_eduvpn.event.on("Old_State_Example", eduvpn.StateType.LEAVE) def example_leave(new_state: str, data: str) ``` To show how this can be done in practice, we will give an example in the next section. diff --git a/wrappers/python/eduvpn_common/event.py b/wrappers/python/eduvpn_common/event.py index a47a0a7..f6260c5 100644 --- a/wrappers/python/eduvpn_common/event.py +++ b/wrappers/python/eduvpn_common/event.py @@ -105,6 +105,6 @@ class EventHandler(object): converted = data if convert: converted = convert_data(self.lib, new_state, data) - self.run_state(old_state, new_state, StateType.Leave, converted) - self.run_state(new_state, old_state, StateType.Enter, converted) - self.run_state(new_state, old_state, StateType.Wait, converted) + self.run_state(old_state, new_state, StateType.LEAVE, converted) + self.run_state(new_state, old_state, StateType.ENTER, converted) + self.run_state(new_state, old_state, StateType.WAIT, converted) diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index 7cb4b5e..f901ce7 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -49,12 +49,12 @@ class EduVPN(object): self.profile_event: Optional[threading.Event] = None self.location_event: Optional[threading.Event] = None - @self.event.on(State.ASK_PROFILE, StateType.Wait) + @self.event.on(State.ASK_PROFILE, StateType.WAIT) def wait_profile_event(old_state: int, profiles: str): if self.profile_event: self.profile_event.wait() - @self.event.on(State.ASK_LOCATION, StateType.Wait) + @self.event.on(State.ASK_LOCATION, StateType.WAIT) def wait_location_event(old_state: int, locations: str): if self.location_event: self.location_event.wait() diff --git a/wrappers/python/eduvpn_common/state.py b/wrappers/python/eduvpn_common/state.py index 5af004f..dfa04c9 100644 --- a/wrappers/python/eduvpn_common/state.py +++ b/wrappers/python/eduvpn_common/state.py @@ -2,9 +2,9 @@ from enum import IntEnum class StateType(IntEnum): - Enter = 1 - Leave = 2 - Wait = 3 + ENTER = 1 + LEAVE = 2 + WAIT = 3 class State(IntEnum): diff --git a/wrappers/python/main.py b/wrappers/python/main.py index 657f0ab..5604452 100644 --- a/wrappers/python/main.py +++ b/wrappers/python/main.py @@ -27,23 +27,23 @@ def ask_profile_input(total: int) -> int: # Sets up the callbacks using the provided class def setup_callbacks(_eduvpn: eduvpn.EduVPN) -> None: # The callback that starst OAuth - @_eduvpn.event.on(State.NO_SERVER, StateType.Enter) + @_eduvpn.event.on(State.NO_SERVER, StateType.ENTER) def no_server(old_state: str, servers) -> None: for server in servers: print(type(server)) print(server) # It needs to open the URL in the web browser - @_eduvpn.event.on(State.OAUTH_STARTED, StateType.Enter) + @_eduvpn.event.on(State.OAUTH_STARTED, StateType.ENTER) def oauth_initialized(old_state: str, url: str) -> None: print(f"Got OAuth URL {url}, old state: {old_state}") webbrowser.open(url) - @_eduvpn.event.on(State.ASK_LOCATION, StateType.Enter) + @_eduvpn.event.on(State.ASK_LOCATION, StateType.ENTER) def ask_location(old_state: str, locations: List[str]): _eduvpn.set_secure_location(locations[1]) ## The callback which asks the user for a profile - #@_eduvpn.event.on(State.ASK_PROFILE, StateType.Enter) + #@_eduvpn.event.on(State.ASK_PROFILE, StateType.ENTER) #def ask_profile(old_state: str, profiles: str): # print("Multiple profiles found, you need to select a profile:") diff --git a/wrappers/python/tests.py b/wrappers/python/tests.py index 679eda0..4e45fbc 100644 --- a/wrappers/python/tests.py +++ b/wrappers/python/tests.py @@ -22,7 +22,7 @@ class ConfigTests(unittest.TestCase): # This can throw an exception _eduvpn.register() - @_eduvpn.event.on(State.OAUTH_STARTED, StateType.Enter) + @_eduvpn.event.on(State.OAUTH_STARTED, StateType.ENTER) def oauth_initialized(old_state, url_json): login_eduvpn(url_json) |
