standalone publish allow project specific plugins

This commit is contained in:
iLLiCiTiT 2020-02-28 15:27:57 +01:00
parent 9ae412bff6
commit c765c02115
3 changed files with 29 additions and 16 deletions

View file

@ -1,3 +1,5 @@
PUBLISH_PATHS = []
from .standalonepublish_module import StandAlonePublishModule
from .app import (
show,

View file

@ -5,14 +5,14 @@ import tempfile
import random
import string
from avalon import io
from avalon import api as avalon
from avalon import io, api
from avalon.tools import publish as av_publish
import pype
from pypeapp import execute
import pyblish.api
from . import PUBLISH_PATHS
def set_context(project, asset, task, app):
@ -31,7 +31,6 @@ def set_context(project, asset, task, app):
os.environ["AVALON_TASK"] = task
io.Session["AVALON_TASK"] = task
io.install()
av_project = io.find_one({'type': 'project'})
@ -76,7 +75,7 @@ def avalon_api_publish(data, gui=True):
io.install()
# Create hash name folder in temp
chars = "".join( [random.choice(string.ascii_letters) for i in range(15)] )
chars = "".join([random.choice(string.ascii_letters) for i in range(15)])
staging_dir = tempfile.mkdtemp(chars)
# create also json and fill with data
@ -105,8 +104,27 @@ def avalon_api_publish(data, gui=True):
def cli_publish(data, gui=True):
io.install()
pyblish.api.deregister_all_plugins()
# Registers Global pyblish plugins
pype.install()
# Registers Standalone pyblish plugins
for path in PUBLISH_PATHS:
pyblish.api.register_plugin_path(path)
project_plugins_paths = os.environ.get("PYPE_PROJECT_PLUGINS")
project_name = os.environ["AVALON_PROJECT"]
if project_plugins_paths and project_name:
for path in project_plugins_paths.split(os.pathsep):
if not path:
continue
plugin_path = os.path.join(path, project_name, "plugins")
if os.path.exists(plugin_path):
pyblish.api.register_plugin_path(plugin_path)
api.register_plugin_path(api.Loader, plugin_path)
api.register_plugin_path(api.Creator, plugin_path)
# Create hash name folder in temp
chars = "".join( [random.choice(string.ascii_letters) for i in range(15)] )
chars = "".join([random.choice(string.ascii_letters) for i in range(15)])
staging_dir = tempfile.mkdtemp(chars)
# create json for return data

View file

@ -2,16 +2,16 @@ import os
from .app import show
from .widgets import QtWidgets
import pype
import pyblish.api
from . import PUBLISH_PATHS
class StandAlonePublishModule:
PUBLISH_PATHS = []
def __init__(self, main_parent=None, parent=None):
self.main_parent = main_parent
self.parent_widget = parent
self.PUBLISH_PATHS.append(os.path.sep.join(
PUBLISH_PATHS.clear()
PUBLISH_PATHS.append(os.path.sep.join(
[pype.PLUGINS_DIR, "standalonepublisher", "publish"]
))
@ -24,16 +24,9 @@ class StandAlonePublishModule:
def process_modules(self, modules):
if "FtrackModule" in modules:
self.PUBLISH_PATHS.append(os.path.sep.join(
PUBLISH_PATHS.append(os.path.sep.join(
[pype.PLUGINS_DIR, "ftrack", "publish"]
))
def tray_start(self):
# Registers Global pyblish plugins
pype.install()
# Registers Standalone pyblish plugins
for path in self.PUBLISH_PATHS:
pyblish.api.register_plugin_path(path)
def show(self):
show(self.main_parent, False)