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)
if not staging_dir:
staging_dir = tempfile.mkdtemp()
staging_dir = tempfile.mkdtemp(prefix="pyblish_tmp_")
instance.data['stagingDir'] = staging_dir
return staging_dir

View file

@ -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)

View file

@ -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)

View file

@ -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"

View file

@ -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):

View file

@ -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.")