Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1949 from pypeclub/feature/host_name_collector
Browse files Browse the repository at this point in the history
Global: Avalon Host name collector
  • Loading branch information
iLLiCiTiT authored Aug 27, 2021
2 parents cd586be + 647f977 commit 3b25d2a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
17 changes: 2 additions & 15 deletions openpype/plugins/publish/collect_anatomy_context_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
37 changes: 37 additions & 0 deletions openpype/plugins/publish/collect_host_name.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion openpype/plugins/publish/extract_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion openpype/plugins/publish/extract_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3b25d2a

Please sign in to comment.