mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
modify publish command
This commit is contained in:
parent
c3cc49d619
commit
25e912aedc
4 changed files with 63 additions and 16 deletions
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Collect sequences from Royal Render Job."""
|
||||
import rr # noqa
|
||||
import rrGlobal # noqa
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
## OpenPype RoyalRender integration plugins
|
||||
|
||||
### Installation
|
||||
|
||||
Copy content of this folder to your `RR_ROOT` (place where RoyalRender studio wide installation is).
|
||||
|
|
@ -22,6 +22,10 @@ class OpenPypeContextSelector:
|
|||
self.job = rr.getJob()
|
||||
self.context = None
|
||||
|
||||
self.openpype_executable = "openpype_gui"
|
||||
if platform.system().lower() == "windows":
|
||||
op_exec = "{}.exe".format(self.openpype_executable)
|
||||
|
||||
op_path = os.environ.get("OPENPYPE_ROOT")
|
||||
print("initializing ... {}".format(op_path))
|
||||
if not op_path:
|
||||
|
|
@ -84,6 +88,9 @@ class OpenPypeContextSelector:
|
|||
if not self.context:
|
||||
self.show()
|
||||
|
||||
self.context["user"] = self.job.userName
|
||||
self.process_job()
|
||||
|
||||
def show(self):
|
||||
"""Show UI for context selection.
|
||||
|
||||
|
|
@ -91,25 +98,31 @@ class OpenPypeContextSelector:
|
|||
itself.
|
||||
|
||||
"""
|
||||
op_exec = "openpype_gui"
|
||||
if platform.system().lower() == "windows":
|
||||
op_exec = "{}.exe".format(op_exec)
|
||||
tf = tempfile.TemporaryFile(delete=False)
|
||||
context_file = tf.name
|
||||
op_args = [os.path.join(self.openpype_root, self.openpype_executable),
|
||||
"contextselection", tf.name]
|
||||
|
||||
with tempfile.TemporaryFile() as tf:
|
||||
op_args = [os.path.join(self.openpype_root, op_exec),
|
||||
"contextselection", tf.name]
|
||||
tf.close()
|
||||
print(">>> running {}".format(op_args))
|
||||
|
||||
print(">>> running {}".format(op_args))
|
||||
subprocess.call(op_args)
|
||||
self.context = json.load(tf)
|
||||
subprocess.call(op_args)
|
||||
|
||||
with open(context_file, "r") as cf:
|
||||
self.context = json.load(cf)
|
||||
|
||||
os.unlink(context_file)
|
||||
print(">>> context: {}".format(self.context))
|
||||
|
||||
if not self.context or \
|
||||
not self.context.project or \
|
||||
not self.context.asset or \
|
||||
not self.context.task:
|
||||
not self.context.get("project") or \
|
||||
not self.context.get("asset") or \
|
||||
not self.context.get("task"):
|
||||
self._show_rr_warning("Context selection failed.")
|
||||
return
|
||||
|
||||
self.context["app_name"] = self.job.renderer.name
|
||||
|
||||
@staticmethod
|
||||
def _show_rr_warning(text):
|
||||
warning_dialog = rrGlobal.getGenericUI()
|
||||
|
|
@ -122,6 +135,23 @@ class OpenPypeContextSelector:
|
|||
warning_dialog.execute()
|
||||
del warning_dialog
|
||||
|
||||
def run_publish(self):
|
||||
"""Run publish process."""
|
||||
env = dict()
|
||||
env["AVALON_PROJECT"] = self.context.get("project")
|
||||
env["AVALON_ASSET"] = self.context.get("asset")
|
||||
env["AVALON_TASK"] = self.context.get("task")
|
||||
env["AVALON_APP_NAME"] = self.context.get("app_name")
|
||||
|
||||
args = list()
|
||||
args.append(
|
||||
os.path.join(self.openpype_root, self.openpype_executable))
|
||||
args.append("publish")
|
||||
args.append("-t")
|
||||
args.append(self.job.imageDir)
|
||||
print(">>> running {}".format(args))
|
||||
subprocess.call(args)
|
||||
|
||||
|
||||
print("running selector")
|
||||
selector = OpenPypeContextSelector()
|
||||
|
|
@ -73,9 +73,7 @@ class PypeCommands:
|
|||
Raises:
|
||||
RuntimeError: When there is no path to process.
|
||||
"""
|
||||
if not any(paths):
|
||||
raise RuntimeError("No publish paths specified")
|
||||
|
||||
from openpype.modules import ModulesManager
|
||||
from openpype import install, uninstall
|
||||
from openpype.api import Logger
|
||||
|
||||
|
|
@ -83,6 +81,15 @@ class PypeCommands:
|
|||
import pyblish.api
|
||||
import pyblish.util
|
||||
|
||||
manager = ModulesManager()
|
||||
enabled_modules = manager.get_enabled_modules()
|
||||
for module in enabled_modules:
|
||||
if hasattr(module, "get_plugin_paths"):
|
||||
pyblish.api.register_plugin_path(module.get_plugin_paths())
|
||||
|
||||
if not any(paths):
|
||||
raise RuntimeError("No publish paths specified")
|
||||
|
||||
env = get_app_environments_for_context(
|
||||
os.environ["AVALON_PROJECT"],
|
||||
os.environ["AVALON_ASSET"],
|
||||
|
|
@ -95,12 +102,13 @@ class PypeCommands:
|
|||
|
||||
install()
|
||||
|
||||
pyblish.api.register_target("filesequence")
|
||||
pyblish.api.register_host("shell")
|
||||
|
||||
if targets:
|
||||
for target in targets:
|
||||
pyblish.api.register_target(target)
|
||||
else:
|
||||
pyblish.api.register_target("filesequence")
|
||||
|
||||
os.environ["OPENPYPE_PUBLISH_DATA"] = os.pathsep.join(paths)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue