use AYON username for user in template data

This commit is contained in:
Jakub Trllo 2023-10-31 13:55:22 +01:00
parent 5e1de5fd7a
commit 00fb722089
2 changed files with 13 additions and 1 deletions

View file

@ -611,6 +611,12 @@ def get_openpype_username():
settings and last option is to use `getpass.getuser()` which returns
machine username.
"""
if AYON_SERVER_ENABLED:
import ayon_api
return ayon_api.get_user()["name"]
username = os.environ.get("OPENPYPE_USERNAME")
if not username:
local_settings = get_local_settings()

View file

@ -1,4 +1,6 @@
import pyblish.api
from openpype import AYON_SERVER_ENABLED
from openpype.lib import get_openpype_username
@ -7,7 +9,11 @@ class CollectCurrentUserPype(pyblish.api.ContextPlugin):
# Order must be after default pyblish-base CollectCurrentUser
order = pyblish.api.CollectorOrder + 0.001
label = "Collect Pype User"
label = (
"Collect AYON User"
if AYON_SERVER_ENABLED
else "Collect OpenPype User"
)
def process(self, context):
user = get_openpype_username()