OP-2019 - extracted headless_publish function to lib

This commit is contained in:
Petr Kalis 2021-11-16 09:43:42 +01:00
parent 15ea66c8fb
commit fabfaac3f5

View file

@ -11,6 +11,21 @@ from openpype.lib.mongo import OpenPypeMongoConnection
from openpype.lib.plugin_tools import parse_json
def headless_publish(log):
"""Runs publish in a opened host with a context and closes Python process.
Host is being closed via ClosePS pyblish plugin which triggers 'exit'
method in ConsoleTrayApp.
"""
dbcon = get_webpublish_conn()
_id = os.environ.get("BATCH_LOG_ID")
if not _id:
log.warning("Unable to store log records, batch will be unfinished!")
return
publish_and_log(dbcon, _id, log, 'CloseAE')
def get_webpublish_conn():
"""Get connection to OP 'webpublishes' collection."""
mongo_client = OpenPypeMongoConnection.get_mongo_client()