mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #1949 from pypeclub/feature/host_name_collector
Global: Avalon Host name collector
This commit is contained in:
commit
3b25d2a255
4 changed files with 41 additions and 17 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
37
openpype/plugins/publish/collect_host_name.py
Normal file
37
openpype/plugins/publish/collect_host_name.py
Normal 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
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue