diff --git a/colorbleed/plugin.py b/colorbleed/plugin.py index 84e64f6392..0ba1fe5ded 100644 --- a/colorbleed/plugin.py +++ b/colorbleed/plugin.py @@ -28,7 +28,7 @@ class Extractor(pyblish.api.InstancePlugin): staging_dir = instance.data.get('stagingDir', None) if not staging_dir: - staging_dir = tempfile.mkdtemp() + staging_dir = tempfile.mkdtemp(prefix="pyblish_tmp_") instance.data['stagingDir'] = staging_dir return staging_dir diff --git a/colorbleed/plugins/maya/publish/validate_model_content.py b/colorbleed/plugins/maya/publish/validate_model_content.py index d953be56bb..1e43754c6d 100644 --- a/colorbleed/plugins/maya/publish/validate_model_content.py +++ b/colorbleed/plugins/maya/publish/validate_model_content.py @@ -37,7 +37,7 @@ class ValidateModelContent(pyblish.api.InstancePlugin): content_instance = list(set(content_instance + descendants)) # Ensure only valid node types - allowed = ('mesh', 'transform', 'nurbsCurve') + allowed = ('mesh', 'transform', 'nurbsCurve', 'nurbsSurface') nodes = cmds.ls(content_instance, long=True) valid = cmds.ls(content_instance, long=True, type=allowed) invalid = set(nodes) - set(valid) diff --git a/colorbleed/plugins/publish/cleanup.py b/colorbleed/plugins/publish/cleanup.py index 742316094f..c17842d357 100644 --- a/colorbleed/plugins/publish/cleanup.py +++ b/colorbleed/plugins/publish/cleanup.py @@ -1,21 +1,32 @@ import os - -from pyblish import api +import pyblish.api -class CleanUp(api.InstancePlugin): - """Cleans up the staging directory after a successful publish +class CleanUp(pyblish.api.InstancePlugin): + """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" def process(self, instance): - 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 ...") - os.rmdir(staging_dir) + 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 + + self.log.info("Removing temporary folder ...") + os.rmdir(staging_dir) diff --git a/colorbleed/plugins/publish/collect_imagesequences.py b/colorbleed/plugins/publish/collect_imagesequences.py index 4da58840c0..4186bd684d 100644 --- a/colorbleed/plugins/publish/collect_imagesequences.py +++ b/colorbleed/plugins/publish/collect_imagesequences.py @@ -6,6 +6,7 @@ class CollectMindbenderImageSequences(pyblish.api.ContextPlugin): """Gather image sequnences from working directory""" order = pyblish.api.CollectorOrder + targets = ["imagesequence"] hosts = ["shell"] label = "Image Sequences" diff --git a/colorbleed/plugins/publish/integrate.py b/colorbleed/plugins/publish/integrate.py index a0ce130bd6..2418971546 100644 --- a/colorbleed/plugins/publish/integrate.py +++ b/colorbleed/plugins/publish/integrate.py @@ -37,15 +37,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin): def process(self, instance): - self.log.info("Integrating Asset in to the database ...") - self.register(instance) - self.integrate(instance) - # TODO: Decide how to clean up? And when? - # self.log.info("Removing temporary files and folders ...") - # stagingdir = instance.data["stagingDir"] - # shutil.rmtree(stagingdir) + self.log.info("Integrating Asset in to the database ...") + self.integrate(instance) def register(self, instance): diff --git a/colorbleed/scripts/publish_imagesequence.py b/colorbleed/scripts/publish_imagesequence.py index f6997d1b06..314daacf09 100644 --- a/colorbleed/scripts/publish_imagesequence.py +++ b/colorbleed/scripts/publish_imagesequence.py @@ -64,13 +64,9 @@ def publish_data(json_file): from avalon import api, 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 import pyblish.util - context = pyblish.util.publish() + context = pyblish.util.publish(targets=["imagesequence"]) if not context: log.warning("Nothing published.")