From 43787fd9c39f16bc8bf75d401b038a5a2fb56988 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Sat, 8 Jun 2024 10:52:37 +0200 Subject: [PATCH] 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()