diff --git a/openpype/plugins/publish/collect_anatomy_context_data.py b/openpype/plugins/publish/collect_anatomy_context_data.py index f121760e274..ec88d5669d4 100644 --- a/openpype/plugins/publish/collect_anatomy_context_data.py +++ b/openpype/plugins/publish/collect_anatomy_context_data.py @@ -62,23 +62,10 @@ def process(self, context): "asset": asset_entity["name"], "hierarchy": hierarchy.replace("\\", "/"), "task": task_name, - "username": context.data["user"] + "username": context.data["user"], + "app": context.data["hostName"] } - # Use AVALON_APP as first if available it is the same as host name - # - only if is not defined use AVALON_APP_NAME (e.g. on Farm) and - # set it back to AVALON_APP env variable - host_name = os.environ.get("AVALON_APP") - if not host_name: - app_manager = ApplicationManager() - app_name = os.environ.get("AVALON_APP_NAME") - if app_name: - app = app_manager.applications.get(app_name) - if app: - host_name = app.host_name - os.environ["AVALON_APP"] = host_name - context_data["app"] = host_name - datetime_data = context.data.get("datetimeData") or {} context_data.update(datetime_data) diff --git a/openpype/plugins/publish/collect_host_name.py b/openpype/plugins/publish/collect_host_name.py new file mode 100644 index 00000000000..41d9cc3a5ab --- /dev/null +++ b/openpype/plugins/publish/collect_host_name.py @@ -0,0 +1,37 @@ +""" +Requires: + None +Provides: + context -> host (str) +""" +import os +import pyblish.api + +from openpype.lib import ApplicationManager + + +class CollectHostName(pyblish.api.ContextPlugin): + """Collect avalon host name to context.""" + + label = "Collect Host Name" + order = pyblish.api.CollectorOrder - 1 + + def process(self, context): + host_name = context.data.get("hostName") + # Don't override value if is already set + if host_name: + return + + # Use AVALON_APP as first if available it is the same as host name + # - only if is not defined use AVALON_APP_NAME (e.g. on Farm) and + # set it back to AVALON_APP env variable + host_name = os.environ.get("AVALON_APP") + if not host_name: + app_name = os.environ.get("AVALON_APP_NAME") + if app_name: + app_manager = ApplicationManager() + app = app_manager.applications.get(app_name) + if app: + host_name = app.host_name + + context.data["hostName"] = host_name diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 91e0a0f3ec9..607d2cbff72 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -96,7 +96,7 @@ def process(self, instance): def main_process(self, instance): # TODO get these data from context - host_name = os.environ["AVALON_APP"] + host_name = instance.context.data["hostName"] task_name = os.environ["AVALON_TASK"] family = self.main_family_from_instance(instance) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index bdcd3b8e600..a9235c3ffa3 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -89,7 +89,7 @@ def process(self, instance): instance.data["representations"].remove(repre) def main_process(self, instance): - host_name = os.environ["AVALON_APP"] + host_name = instance.context.data["hostName"] task_name = os.environ["AVALON_TASK"] family = self.main_family_from_instance(instance)