From 21329b113fdc782dbc7379e7636ae78401a24219 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 11 Jan 2018 10:13:24 +0100 Subject: [PATCH 1/6] Add pyblish prefix to temp dir --- colorbleed/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 4fe087bff333132ce28e827f2fa503d6b92d2cbd Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 15 Jan 2018 10:28:10 +0100 Subject: [PATCH 2/6] Move integration logged message only when "integrate" starts --- colorbleed/plugins/publish/integrate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colorbleed/plugins/publish/integrate.py b/colorbleed/plugins/publish/integrate.py index a0ce130bd6..1221ddc217 100644 --- a/colorbleed/plugins/publish/integrate.py +++ b/colorbleed/plugins/publish/integrate.py @@ -37,9 +37,9 @@ class IntegrateAsset(pyblish.api.InstancePlugin): def process(self, instance): - self.log.info("Integrating Asset in to the database ...") - self.register(instance) + + self.log.info("Integrating Asset in to the database ...") self.integrate(instance) # TODO: Decide how to clean up? And when? From 581a5a0d3f19f9174e60fc31e740509a538b69d4 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 15 Jan 2018 10:29:37 +0100 Subject: [PATCH 3/6] Use Pyblish's new `targets` workflow for "imagesequence" --- colorbleed/plugins/publish/collect_imagesequences.py | 1 + colorbleed/scripts/publish_imagesequence.py | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) 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/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.") From 649acbad0adf2f577aa152838d13dc6b28f14a93 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 15 Jan 2018 10:31:16 +0100 Subject: [PATCH 4/6] Enable and implement clean up plug-in --- colorbleed/plugins/publish/cleanup.py | 33 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) 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) From 7427d5a2861df0e0460d7225ff7fbb98b43b959b Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 15 Jan 2018 10:44:46 +0100 Subject: [PATCH 5/6] Remove commented out clean up code in favor of clean up plug-in --- colorbleed/plugins/publish/integrate.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/colorbleed/plugins/publish/integrate.py b/colorbleed/plugins/publish/integrate.py index 1221ddc217..2418971546 100644 --- a/colorbleed/plugins/publish/integrate.py +++ b/colorbleed/plugins/publish/integrate.py @@ -42,11 +42,6 @@ class IntegrateAsset(pyblish.api.InstancePlugin): self.log.info("Integrating Asset in to the database ...") 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) - def register(self, instance): # Required environment variables From e44cb87b584d55a1c6960c6e627546082b1e76a1 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 15 Jan 2018 11:07:29 +0100 Subject: [PATCH 6/6] Allow nurbsSurface to be be published with a model --- colorbleed/plugins/maya/publish/validate_model_content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)