This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1949 from pypeclub/feature/host_name_collector
Global: Avalon Host name collector
- Loading branch information
Showing
4 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters