From b10fb57bd9689725f6e5d9224b1753009b1fdbc2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:00:40 +0200 Subject: [PATCH 1/5] update ayon api to '1.0.10' --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index d32568091..43fcb276b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -260,13 +260,13 @@ tomli = {version = "*", markers = "python_version < \"3.11\""} [[package]] name = "ayon-python-api" -version = "1.0.9" +version = "1.0.10" description = "AYON Python API" optional = false python-versions = "*" files = [ - {file = "ayon-python-api-1.0.9.tar.gz", hash = "sha256:d1a3d467bdcb5a27120fed59d8996e97b6ef4d56a570b5957df922fc5ef58074"}, - {file = "ayon_python_api-1.0.9-py3-none-any.whl", hash = "sha256:0e4d623befe24bfb4c0c58746f49cbfe182d48ab13cd743177d1af3702e0de43"}, + {file = "ayon-python-api-1.0.10.tar.gz", hash = "sha256:d6a3036dc986e59e9dc93395ab2930d3815060b7f258e361758ab2aac662d5a7"}, + {file = "ayon_python_api-1.0.10-py3-none-any.whl", hash = "sha256:2af0587666bbf4cb2f9289f00a62f65a141dc0f0e36ea2a66628a9ab144cb05f"}, ] [package.dependencies] @@ -2386,4 +2386,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.9.1,<3.10" -content-hash = "13c774f6fa732fca441e529f8b502a8c7de211d665c84ba1ef310e96f4472989" +content-hash = "e126aceccda98558e7f407bc9e3f048d58579fcd0cbb75ff71e34a9dc45b3b00" From 1c95757e1c5bbb16219af238e1239757be235e3a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:01:27 +0200 Subject: [PATCH 2/5] fix hash --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 43fcb276b..d21414d21 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2386,4 +2386,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.9.1,<3.10" -content-hash = "e126aceccda98558e7f407bc9e3f048d58579fcd0cbb75ff71e34a9dc45b3b00" +content-hash = "13c774f6fa732fca441e529f8b502a8c7de211d665c84ba1ef310e96f4472989" From ca572d4223b20755db362a5e4c79252ed36da196 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:04:02 +0200 Subject: [PATCH 3/5] use methods from ayon api to work with webaction events --- start.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/start.py b/start.py index 7bd7e3e06..259f7c912 100644 --- a/start.py +++ b/start.py @@ -261,7 +261,6 @@ def _is_in_login_mode(): import blessed # noqa: E402 import certifi # noqa: E402 -import requests # noqa: E402 if sys.__stdout__: @@ -309,6 +308,8 @@ def _print(message: str): get_addons_studio_settings, get_event, update_event, + take_web_action_event, + abort_web_action_event, ) from ayon_api.constants import ( # noqa E402 SERVER_URL_ENV_KEY, @@ -738,9 +739,7 @@ def process_uri(): server_url = parsed_query["server_url"][0] uri_token = parsed_query["token"][0] # Use raw requests to get all necessary information from server - response = requests.get(f"{server_url}/api/actions/take/{uri_token}") - # TODO validate response - data = response.json() + data = take_web_action_event(server_url, uri_token) username = data.get("userName") os.environ[SERVER_URL_ENV_KEY] = server_url @@ -752,9 +751,10 @@ def process_uri(): _connect_to_ayon_server(username=username) except SystemExit: try: - requests.post( - f"{server_url}/api/actions/abort/{uri_token}", - json={"message": "User skipped login in AYON launcher."} + abort_web_action_event( + server_url, + uri_token, + "User skipped login in AYON launcher.", ) except Exception: # Silently ignore any exception, only print traceback From 6b3f63987892c889a4431411efcc7e7991a0fa51 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:32:48 +0200 Subject: [PATCH 4/5] use correct endpoint --- start.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/start.py b/start.py index 259f7c912..7d761dbc5 100644 --- a/start.py +++ b/start.py @@ -261,6 +261,7 @@ def _is_in_login_mode(): import blessed # noqa: E402 import certifi # noqa: E402 +import requests # noqa: E402 if sys.__stdout__: @@ -751,10 +752,9 @@ def process_uri(): _connect_to_ayon_server(username=username) except SystemExit: try: - abort_web_action_event( - server_url, - uri_token, - "User skipped login in AYON launcher.", + response = requests.post( + f"{server_url}/api/actions/abort/{uri_token}", + json={"message": "User skipped login in AYON launcher."}, ) except Exception: # Silently ignore any exception, only print traceback From 943df296a2f17694315ca374c61d9ae24534d2b4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:40:51 +0200 Subject: [PATCH 5/5] added commented function with comment --- start.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/start.py b/start.py index 7d761dbc5..f6099a247 100644 --- a/start.py +++ b/start.py @@ -752,7 +752,13 @@ def process_uri(): _connect_to_ayon_server(username=username) except SystemExit: try: - response = requests.post( + # There is a bug in ayon-python-api 1.0.10 + # abort_web_action_event( + # server_url, + # uri_token, + # "User skipped login in AYON launcher.", + # ) + requests.post( f"{server_url}/api/actions/abort/{uri_token}", json={"message": "User skipped login in AYON launcher."}, )