From 06f15809ff177cecfea86913c7cf117252fad505 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Mon, 28 Oct 2024 14:18:15 -0400 Subject: [PATCH] Allow user override through AYON_USERNAME. --- client/ayon_traypublisher/addon.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/ayon_traypublisher/addon.py b/client/ayon_traypublisher/addon.py index dd78a70..7b8e796 100644 --- a/client/ayon_traypublisher/addon.py +++ b/client/ayon_traypublisher/addon.py @@ -1,6 +1,9 @@ import os from pathlib import Path + +import ayon_api + from ayon_core.lib import get_ayon_launcher_args from ayon_core.lib.execute import run_detached_process from ayon_core.addon import ( @@ -109,6 +112,13 @@ def ingestcsv( """ from .csv_publish import csvpublish + # Allow user override through AYON_USERNAME when + # current connection is made through a service user. + username = os.environ.get("AYON_USERNAME") + con = ayon_api.get_server_api_connection() + if username and con.is_service_user(): + con.set_default_service_username(username) + # use Path to check if csv_filepath exists if not Path(filepath).exists(): raise FileNotFoundError(f"File {filepath} does not exist.")