open publish gui

This commit is contained in:
Ondrej Samohel 2021-11-10 18:41:33 +01:00 committed by Ondřej Samohel
parent 38ad390cd9
commit ebce633383
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
3 changed files with 26 additions and 13 deletions

View file

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

View file

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

View file

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