From b2c06b937bc8d148ec8e81485232d9ecc93ac030 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 19 Aug 2021 16:53:25 +0200 Subject: [PATCH 1/6] added collector for avalon host name --- openpype/plugins/publish/collect_host_name.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 openpype/plugins/publish/collect_host_name.py diff --git a/openpype/plugins/publish/collect_host_name.py b/openpype/plugins/publish/collect_host_name.py new file mode 100644 index 0000000000..897c50e4d8 --- /dev/null +++ b/openpype/plugins/publish/collect_host_name.py @@ -0,0 +1,21 @@ +""" +Requires: + None +Provides: + context -> host (str) +""" +import os +import pyblish.api + + +class CollectHostName(pyblish.api.ContextPlugin): + """Collect avalon host name to context.""" + + label = "Collect Host Name" + order = pyblish.api.CollectorOrder + + def process(self, context): + # Don't override value if is already set + host_name = context.data.get("host") + if not host_name: + context.data["host"] = os.environ.get("AVALON_APP") From 64a186b437844711e0501a4a848c45ff13fa7d06 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 19 Aug 2021 17:00:18 +0200 Subject: [PATCH 2/6] moved host collection from collect anatomy context data --- .../publish/collect_anatomy_context_data.py | 17 ++-------------- openpype/plugins/publish/collect_host_name.py | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/openpype/plugins/publish/collect_anatomy_context_data.py b/openpype/plugins/publish/collect_anatomy_context_data.py index f121760e27..33db00636a 100644 --- a/openpype/plugins/publish/collect_anatomy_context_data.py +++ b/openpype/plugins/publish/collect_anatomy_context_data.py @@ -62,23 +62,10 @@ class CollectAnatomyContextData(pyblish.api.ContextPlugin): "asset": asset_entity["name"], "hierarchy": hierarchy.replace("\\", "/"), "task": task_name, - "username": context.data["user"] + "username": context.data["user"], + "app": context.data["host"] } - # 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 index 897c50e4d8..17af9253c3 100644 --- a/openpype/plugins/publish/collect_host_name.py +++ b/openpype/plugins/publish/collect_host_name.py @@ -7,6 +7,8 @@ Provides: import os import pyblish.api +from openpype.lib import ApplicationManager + class CollectHostName(pyblish.api.ContextPlugin): """Collect avalon host name to context.""" @@ -15,7 +17,21 @@ class CollectHostName(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder def process(self, context): - # Don't override value if is already set host_name = context.data.get("host") + # 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: - context.data["host"] = os.environ.get("AVALON_APP") + 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["host"] = host_name From 46fd7ee628afaee99c71c8157180a60f3d861ea6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 19 Aug 2021 17:00:34 +0200 Subject: [PATCH 3/6] use context[host] in extract review and burnin --- openpype/plugins/publish/extract_burnin.py | 2 +- openpype/plugins/publish/extract_review.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 91e0a0f3ec..b0c6136694 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -96,7 +96,7 @@ class ExtractBurnin(openpype.api.Extractor): def main_process(self, instance): # TODO get these data from context - host_name = os.environ["AVALON_APP"] + host_name = instance.context["host"] 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 bdcd3b8e60..3b373bc1d6 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -89,7 +89,7 @@ class ExtractReview(pyblish.api.InstancePlugin): instance.data["representations"].remove(repre) def main_process(self, instance): - host_name = os.environ["AVALON_APP"] + host_name = instance.context["host"] task_name = os.environ["AVALON_TASK"] family = self.main_family_from_instance(instance) From 5d182faae26797764b2cdb98ee369c6600f5679c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 23 Aug 2021 12:25:44 +0200 Subject: [PATCH 4/6] changed context key from "host" to "hostName" --- openpype/plugins/publish/collect_anatomy_context_data.py | 2 +- openpype/plugins/publish/collect_host_name.py | 4 ++-- openpype/plugins/publish/extract_burnin.py | 2 +- openpype/plugins/publish/extract_review.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openpype/plugins/publish/collect_anatomy_context_data.py b/openpype/plugins/publish/collect_anatomy_context_data.py index 33db00636a..ec88d5669d 100644 --- a/openpype/plugins/publish/collect_anatomy_context_data.py +++ b/openpype/plugins/publish/collect_anatomy_context_data.py @@ -63,7 +63,7 @@ class CollectAnatomyContextData(pyblish.api.ContextPlugin): "hierarchy": hierarchy.replace("\\", "/"), "task": task_name, "username": context.data["user"], - "app": context.data["host"] + "app": context.data["hostName"] } datetime_data = context.data.get("datetimeData") or {} diff --git a/openpype/plugins/publish/collect_host_name.py b/openpype/plugins/publish/collect_host_name.py index 17af9253c3..e1b7eb17c3 100644 --- a/openpype/plugins/publish/collect_host_name.py +++ b/openpype/plugins/publish/collect_host_name.py @@ -17,7 +17,7 @@ class CollectHostName(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder def process(self, context): - host_name = context.data.get("host") + host_name = context.data.get("hostName") # Don't override value if is already set if host_name: return @@ -34,4 +34,4 @@ class CollectHostName(pyblish.api.ContextPlugin): if app: host_name = app.host_name - context.data["host"] = host_name + context.data["hostName"] = host_name diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index b0c6136694..8fef5eaacb 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -96,7 +96,7 @@ class ExtractBurnin(openpype.api.Extractor): def main_process(self, instance): # TODO get these data from context - host_name = instance.context["host"] + host_name = instance.context["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 3b373bc1d6..cdd40af027 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -89,7 +89,7 @@ class ExtractReview(pyblish.api.InstancePlugin): instance.data["representations"].remove(repre) def main_process(self, instance): - host_name = instance.context["host"] + host_name = instance.context["hostName"] task_name = os.environ["AVALON_TASK"] family = self.main_family_from_instance(instance) From c67b647dc78614779075774e5180261d2f6dc7f6 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 25 Aug 2021 10:16:10 +0200 Subject: [PATCH 5/6] Fix context.data --- openpype/plugins/publish/extract_burnin.py | 2 +- openpype/plugins/publish/extract_review.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 8fef5eaacb..607d2cbff7 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -96,7 +96,7 @@ class ExtractBurnin(openpype.api.Extractor): def main_process(self, instance): # TODO get these data from context - host_name = instance.context["hostName"] + 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 cdd40af027..a9235c3ffa 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -89,7 +89,7 @@ class ExtractReview(pyblish.api.InstancePlugin): instance.data["representations"].remove(repre) def main_process(self, instance): - host_name = instance.context["hostName"] + host_name = instance.context.data["hostName"] task_name = os.environ["AVALON_TASK"] family = self.main_family_from_instance(instance) From 647f9779acb8cbbfa82848097dc47bfba0cb2bde Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 25 Aug 2021 12:53:11 +0200 Subject: [PATCH 6/6] moved host name collector earlier --- openpype/plugins/publish/collect_host_name.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/collect_host_name.py b/openpype/plugins/publish/collect_host_name.py index e1b7eb17c3..41d9cc3a5a 100644 --- a/openpype/plugins/publish/collect_host_name.py +++ b/openpype/plugins/publish/collect_host_name.py @@ -14,7 +14,7 @@ class CollectHostName(pyblish.api.ContextPlugin): """Collect avalon host name to context.""" label = "Collect Host Name" - order = pyblish.api.CollectorOrder + order = pyblish.api.CollectorOrder - 1 def process(self, context): host_name = context.data.get("hostName")