Merge pull request #1949 from pypeclub/feature/host_name_collector

Global: Avalon Host name collector
This commit is contained in:
Jakub Trllo 2021-08-27 13:28:12 +02:00 committed by GitHub
commit 3b25d2a255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 17 deletions

View file

@ -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["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)

View file

@ -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

View file

@ -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.data["hostName"]
task_name = os.environ["AVALON_TASK"]
family = self.main_family_from_instance(instance)

View file

@ -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.data["hostName"]
task_name = os.environ["AVALON_TASK"]
family = self.main_family_from_instance(instance)