global collect host name is not dependent on application addon

This commit is contained in:
Jakub Trllo 2024-03-28 11:20:41 +01:00
parent fbebf98d97
commit 4af3e1cc3b

View file

@ -1,14 +1,13 @@
"""
Requires:
None
Provides:
context -> host (str)
context -> hostName (str)
"""
import os
import pyblish.api
from ayon_core.lib import ApplicationManager
class CollectHostName(pyblish.api.ContextPlugin):
"""Collect avalon host name to context."""
@ -18,30 +17,8 @@ class CollectHostName(pyblish.api.ContextPlugin):
def process(self, context):
host_name = context.data.get("hostName")
app_name = context.data.get("appName")
app_label = context.data.get("appLabel")
# Don't override value if is already set
if host_name and app_name and app_label:
if host_name:
return
# Use AYON_HOST_NAME to get host name if available
if not host_name:
host_name = os.environ.get("AYON_HOST_NAME")
# Use AYON_APP_NAME to get full app name
if not app_name:
app_name = os.environ.get("AYON_APP_NAME")
# Fill missing values based on app full name
if (not host_name or not app_label) and app_name:
app_manager = ApplicationManager()
app = app_manager.applications.get(app_name)
if app:
if not host_name:
host_name = app.host_name
if not app_label:
app_label = app.full_label
context.data["hostName"] = host_name
context.data["appName"] = app_name
context.data["appLabel"] = app_label
context.data["hostName"] = os.environ.get("AYON_HOST_NAME")