Merge pull request #82 from BigRoy/master

Enable clean up, allow nurbsSurface in model and minor changes
This commit is contained in:
Roy Nieterau 2018-01-15 11:10:33 +01:00 committed by GitHub
commit 041f3ff7ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 25 deletions

View file

@ -28,7 +28,7 @@ class Extractor(pyblish.api.InstancePlugin):
staging_dir = instance.data.get('stagingDir', None) staging_dir = instance.data.get('stagingDir', None)
if not staging_dir: if not staging_dir:
staging_dir = tempfile.mkdtemp() staging_dir = tempfile.mkdtemp(prefix="pyblish_tmp_")
instance.data['stagingDir'] = staging_dir instance.data['stagingDir'] = staging_dir
return staging_dir return staging_dir

View file

@ -37,7 +37,7 @@ class ValidateModelContent(pyblish.api.InstancePlugin):
content_instance = list(set(content_instance + descendants)) content_instance = list(set(content_instance + descendants))
# Ensure only valid node types # Ensure only valid node types
allowed = ('mesh', 'transform', 'nurbsCurve') allowed = ('mesh', 'transform', 'nurbsCurve', 'nurbsSurface')
nodes = cmds.ls(content_instance, long=True) nodes = cmds.ls(content_instance, long=True)
valid = cmds.ls(content_instance, long=True, type=allowed) valid = cmds.ls(content_instance, long=True, type=allowed)
invalid = set(nodes) - set(valid) invalid = set(nodes) - set(valid)

View file

@ -1,21 +1,32 @@
import os import os
import pyblish.api
from pyblish import api
class CleanUp(api.InstancePlugin): class CleanUp(pyblish.api.InstancePlugin):
"""Cleans up the staging directory after a successful publish """Cleans up the staging directory after a successful publish.
The removal will only happen for staging directories which are inside the
temporary folder, otherwise the folder is ignored.
""" """
order = api.IntegratorOrder + 10 order = pyblish.api.IntegratorOrder + 10
label = "Clean Up" label = "Clean Up"
def process(self, instance): def process(self, instance):
import tempfile
staging_dir = instance.data.get("stagingDir", None)
if not staging_dir or not os.path.exists(staging_dir):
self.log.info("No staging directory found: %s" % staging_dir)
return
temp_root = tempfile.gettempdir()
if not os.path.normpath(staging_dir).startswith(temp_root):
self.log.info("Skipping cleanup. Staging directory is not in the "
"temp folder: %s" % staging_dir)
return return
def clean_up(self, instance):
staging_dir = instance.get("stagingDir", None)
if staging_dir and os.path.exists(staging_dir):
self.log.info("Removing temporary folder ...") self.log.info("Removing temporary folder ...")
os.rmdir(staging_dir) os.rmdir(staging_dir)

View file

@ -6,6 +6,7 @@ class CollectMindbenderImageSequences(pyblish.api.ContextPlugin):
"""Gather image sequnences from working directory""" """Gather image sequnences from working directory"""
order = pyblish.api.CollectorOrder order = pyblish.api.CollectorOrder
targets = ["imagesequence"]
hosts = ["shell"] hosts = ["shell"]
label = "Image Sequences" label = "Image Sequences"

View file

@ -37,15 +37,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
def process(self, instance): def process(self, instance):
self.log.info("Integrating Asset in to the database ...")
self.register(instance) self.register(instance)
self.integrate(instance)
# TODO: Decide how to clean up? And when? self.log.info("Integrating Asset in to the database ...")
# self.log.info("Removing temporary files and folders ...") self.integrate(instance)
# stagingdir = instance.data["stagingDir"]
# shutil.rmtree(stagingdir)
def register(self, instance): def register(self, instance):

View file

@ -64,13 +64,9 @@ def publish_data(json_file):
from avalon import api, shell from avalon import api, shell
api.install(shell) api.install(shell)
# Add environment variable to force collector to use a single folder
# based on the given JSON file
os.environ['USE_JSON'] = str(json_file)
# Publish items, returns context instances # Publish items, returns context instances
import pyblish.util import pyblish.util
context = pyblish.util.publish() context = pyblish.util.publish(targets=["imagesequence"])
if not context: if not context:
log.warning("Nothing published.") log.warning("Nothing published.")