diff --git a/openpype/cli.py b/openpype/cli.py index f6366f4b6b..b4b1b4481e 100644 --- a/openpype/cli.py +++ b/openpype/cli.py @@ -147,7 +147,9 @@ def extractenvironments(output_json_path, project, asset, task, app): @click.option("-d", "--debug", is_flag=True, help="Print debug messages") @click.option("-t", "--targets", help="Targets module", default=None, multiple=True) -def publish(debug, paths, targets): +@click.option("-g", "--gui", is_flag=True, + help="Show Publish UI", default=False) +def publish(debug, paths, targets, gui): """Start CLI publishing. Publish collects json from paths provided as an argument. @@ -155,7 +157,7 @@ def publish(debug, paths, targets): """ if debug: os.environ['OPENPYPE_DEBUG'] = '3' - PypeCommands.publish(list(paths), targets) + PypeCommands.publish(list(paths), targets, gui) @main.command() diff --git a/openpype/modules/default_modules/royal_render/rr_root/plugins/control_job/perjob/m50__openpype_publish_render.py b/openpype/modules/default_modules/royal_render/rr_root/plugins/control_job/perjob/m50__openpype_publish_render.py index cd53e4234f..b993bd9e68 100644 --- a/openpype/modules/default_modules/royal_render/rr_root/plugins/control_job/perjob/m50__openpype_publish_render.py +++ b/openpype/modules/default_modules/royal_render/rr_root/plugins/control_job/perjob/m50__openpype_publish_render.py @@ -8,6 +8,7 @@ run it needs `OPENPYPE_ROOT` to be set to know where to execute OpenPype. import rr # noqa import rrGlobal # noqa import subprocess +from subprocess import list2cmdline import os import glob import platform @@ -44,7 +45,7 @@ class OpenPypeContextSelector: # try to find in user local context op_path = os.path.join( os.environ.get("LOCALAPPDATA"), - "Programs" + "Programs", "OpenPype", "openpype_console.exe" ) if os.path.exists(op_path): @@ -122,7 +123,8 @@ class OpenPypeContextSelector: self._show_rr_warning("Context selection failed.") return - self.context["app_name"] = self.job.renderer.name + # self.context["app_name"] = self.job.renderer.name + self.context["app_name"] = "maya/2020" @staticmethod def _show_rr_warning(text): @@ -147,12 +149,14 @@ class OpenPypeContextSelector: for k, v in env.items(): print(" {}: {}".format(k, v)) args = [os.path.join(self.openpype_root, self.openpype_executable), - 'publish', '-t', "rr_control", self.job.imageDir] + 'publish', '-t', "rr_control", "--gui", self.job.imageDir] print(">>> running {}".format(" ".join(args))) out = None + orig = os.environ.copy() + orig.update(env) try: - out = subprocess.check_output(args, env=env) + subprocess.call(args, env=orig) except subprocess.CalledProcessError as e: self._show_rr_warning(" Publish failed [ {} ]\n{}".format( e.returncode, out diff --git a/openpype/pype_commands.py b/openpype/pype_commands.py index 433aafe30d..bad01396db 100644 --- a/openpype/pype_commands.py +++ b/openpype/pype_commands.py @@ -60,7 +60,7 @@ class PypeCommands: standalonepublish.main() @staticmethod - def publish(paths, targets=None): + def publish(paths, targets=None, gui=False): """Start headless publishing. Publish use json from passed paths argument. @@ -69,6 +69,7 @@ class PypeCommands: paths (list): Paths to jsons. targets (string): What module should be targeted (to choose validator for example) + gui (bool): Show publish UI. Raises: RuntimeError: When there is no path to process. @@ -76,6 +77,8 @@ class PypeCommands: from openpype.modules import ModulesManager from openpype import install, uninstall from openpype.api import Logger + from openpype.tools.utils.host_tools import show_publish + from openpype.tools.utils.lib import qt_app_context # Register target and host import pyblish.api @@ -125,14 +128,18 @@ class PypeCommands: for plugin in plugins: print(plugin) - for result in pyblish.util.publish_iter(): - if result["error"]: - log.error(error_format.format(**result)) - uninstall() - sys.exit(1) + if gui: + with qt_app_context(): + show_publish() + else: + for result in pyblish.util.publish_iter(): + if result["error"]: + log.error(error_format.format(**result)) + # uninstall() + sys.exit(1) log.info("Publish finished.") - uninstall() + # uninstall() @staticmethod def remotepublishfromapp(project, batch_dir, host, user, targets=None):