mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #1039 from pypeclub/feature/publish_cli_command
Publish command in Pype cli
This commit is contained in:
commit
d64083dd49
2 changed files with 46 additions and 6 deletions
|
|
@ -131,9 +131,8 @@ def extractenvironments(output_json_path, project, asset, task, app):
|
|||
|
||||
@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.
|
||||
|
|
@ -141,7 +140,7 @@ def publish(gui, debug, paths):
|
|||
"""
|
||||
if debug:
|
||||
os.environ['PYPE_DEBUG'] = '3'
|
||||
PypeCommands().publish(gui, list(paths))
|
||||
PypeCommands.publish(list(paths))
|
||||
|
||||
|
||||
@main.command()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,50 @@ class PypeCommands:
|
|||
standalonepublish.main()
|
||||
|
||||
@staticmethod
|
||||
def publish(paths):
|
||||
"""Start headless publishing.
|
||||
|
||||
Publish use json from passed 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 extractenvironments(output_json_path, project, asset, task, app):
|
||||
env = os.environ.copy()
|
||||
if all((project, asset, task, app)):
|
||||
|
|
@ -57,9 +101,6 @@ class PypeCommands:
|
|||
with open(output_json_path, "w") as file_stream:
|
||||
json.dump(env, file_stream, indent=4)
|
||||
|
||||
def publish(self, gui, paths):
|
||||
pass
|
||||
|
||||
def texture_copy(self, project, asset, path):
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue