From 43787fd9c39f16bc8bf75d401b038a5a2fb56988 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Sat, 8 Jun 2024 10:52:37 +0200 Subject: [PATCH 1/2] use AYON_USERNAME during publishing --- client/ayon_core/cli_commands.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/cli_commands.py b/client/ayon_core/cli_commands.py index 0fb18be687..c56ed16f1c 100644 --- a/client/ayon_core/cli_commands.py +++ b/client/ayon_core/cli_commands.py @@ -64,9 +64,10 @@ class Commands: get_global_context, ) - # Register target and host + import ayon_api import pyblish.util + # Register target and host if not isinstance(path, str): raise RuntimeError("Path to JSON must be a string.") @@ -86,6 +87,18 @@ class Commands: log = Logger.get_logger("CLI-publish") + # Make public ayon api behave as other user + # - this works only if public ayon api is using service user + username = os.environ.get("AYON_USERNAME") + if username: + # NOTE: ayon-python-api does not have public api function to find + # out if is used service user. So we need to have try > except + # block. + try: + ayon_api.set_default_service_username(username) + except ValueError: + pass + install_ayon_plugins() manager = AddonsManager() From 8a5a078c29eaefbd08358d7f7b3bea41cb0cb0e5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:50:37 +0200 Subject: [PATCH 2/2] use 'get_server_api_connection' to get connection --- client/ayon_core/cli_commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/cli_commands.py b/client/ayon_core/cli_commands.py index c56ed16f1c..ca0693db2f 100644 --- a/client/ayon_core/cli_commands.py +++ b/client/ayon_core/cli_commands.py @@ -94,8 +94,9 @@ class Commands: # NOTE: ayon-python-api does not have public api function to find # out if is used service user. So we need to have try > except # block. + con = ayon_api.get_server_api_connection() try: - ayon_api.set_default_service_username(username) + con.set_default_service_username(username) except ValueError: pass