From c3144123251105816eb03e3288334f304a33b7f4 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 19 Feb 2021 14:11:45 +0100 Subject: [PATCH 1/3] removed gui option from publish command --- pype/cli.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pype/cli.py b/pype/cli.py index 137ae327b2..4c684d72cb 100644 --- a/pype/cli.py +++ b/pype/cli.py @@ -110,9 +110,8 @@ def eventserver(debug, @main.command() @click.argument("paths", nargs=-1) -@click.option("-g", "--gui", is_flag=True, help="Run pyblish GUI") @click.option("-d", "--debug", is_flag=True, help="Print debug messages") -def publish(gui, debug, paths): +def publish(debug, paths): """Start CLI publishing. Publish collects json from paths provided as an argument. @@ -120,7 +119,7 @@ def publish(gui, debug, paths): """ if debug: os.environ['PYPE_DEBUG'] = '3' - PypeCommands().publish(gui, list(paths)) + PypeCommands().publish(list(paths)) @main.command() From ae6041638426fe7d169415cabc170f2a1773f156 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 19 Feb 2021 14:25:35 +0100 Subject: [PATCH 2/3] implemented publish method in pype commands --- pype/pype_commands.py | 47 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/pype/pype_commands.py b/pype/pype_commands.py index 58a3fe738c..6eb1eacdfc 100644 --- a/pype/pype_commands.py +++ b/pype/pype_commands.py @@ -40,8 +40,51 @@ class PypeCommands: from pype.tools import standalonepublish standalonepublish.main() - def publish(self, gui, paths): - pass + @staticmethod + def publish(paths): + """Start headless publishing. + + Publish collects json from current working directory + or supplied paths argument. + + Args: + paths (list): Paths to jsons. + + Raises: + RuntimeError: When there is no pathto process. + """ + if not any(paths): + raise RuntimeError("No publish paths specified") + + from pype import install, uninstall + from pype.api import Logger + + # Register target and host + import pyblish.api + import pyblish.util + + log = Logger.get_logger() + + install() + + pyblish.api.register_target("filesequence") + pyblish.api.register_host("shell") + + os.environ["PYPE_PUBLISH_DATA"] = os.pathsep.join(paths) + + log.info("Running publish ...") + + # Error exit as soon as any error occurs. + error_format = "Failed {plugin.__name__}: {error} -- {error.traceback}" + + 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() def texture_copy(self, project, asset, path): pass From 07e86976662041098c70b8ca1c41b3304e618163 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 19 Feb 2021 14:30:31 +0100 Subject: [PATCH 3/3] modified docstring --- pype/cli.py | 2 +- pype/pype_commands.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pype/cli.py b/pype/cli.py index 4c684d72cb..7d499cbc75 100644 --- a/pype/cli.py +++ b/pype/cli.py @@ -119,7 +119,7 @@ def publish(debug, paths): """ if debug: os.environ['PYPE_DEBUG'] = '3' - PypeCommands().publish(list(paths)) + PypeCommands.publish(list(paths)) @main.command() diff --git a/pype/pype_commands.py b/pype/pype_commands.py index 6eb1eacdfc..41824d0f7f 100644 --- a/pype/pype_commands.py +++ b/pype/pype_commands.py @@ -44,8 +44,7 @@ class PypeCommands: def publish(paths): """Start headless publishing. - Publish collects json from current working directory - or supplied paths argument. + Publish use json from passed paths argument. Args: paths (list): Paths to jsons.