mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
BigRoy comment - add expoted files to 'cleanupFullPaths and staging dirs to 'cleanupEmptyDirs'
This commit is contained in:
parent
fb9261a832
commit
2413a76e9c
2 changed files with 40 additions and 32 deletions
|
|
@ -3,23 +3,20 @@ import os
|
|||
from ayon_core.pipeline import AYONPyblishPluginMixin
|
||||
|
||||
|
||||
class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin,
|
||||
AYONPyblishPluginMixin):
|
||||
"""Collect Staging Directories For Cleaning Up.
|
||||
class CollectFilesForCleaningUp(pyblish.api.InstancePlugin,
|
||||
AYONPyblishPluginMixin):
|
||||
"""Collect Files For Cleaning Up.
|
||||
|
||||
This collector collects staging directories
|
||||
This collector collects output files
|
||||
and adds them to file remove list.
|
||||
|
||||
CAUTION:
|
||||
This collector deletes the parent folder of the exported files.
|
||||
It works fine with the default filepaths in the creators.
|
||||
Artist should be aware with that fact so they take care when
|
||||
changing the file path in the ROP node.
|
||||
Developers should be aware when changing the filepath pattern
|
||||
in creator plugins.
|
||||
This collector deletes the exported files and
|
||||
deletes the parent folder if it was empty.
|
||||
Artists are free to change the file path in the ROP node.
|
||||
"""
|
||||
|
||||
order = pyblish.api.CollectorOrder
|
||||
order = pyblish.api.CollectorOrder + 0.2 # it should run after CollectFrames
|
||||
|
||||
hosts = ["houdini"]
|
||||
families = [
|
||||
|
|
@ -32,16 +29,35 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin,
|
|||
"review",
|
||||
"staticMesh",
|
||||
"usd",
|
||||
"vdbcache",
|
||||
"vdbcache"
|
||||
]
|
||||
label = "Collect Staging Directories For Cleaning Up"
|
||||
label = "Collect Files For Cleaning Up"
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
import hou
|
||||
|
||||
node = hou.node(instance.data["instance_node"])
|
||||
filepath = self.get_filepath(node)
|
||||
|
||||
if not filepath:
|
||||
self.log.warning("No filepath value to collect.")
|
||||
return
|
||||
|
||||
staging_dir, _ = os.path.split(filepath)
|
||||
files = instance.data.get("frames", [])
|
||||
if files:
|
||||
files = ["{}/{}".format(staging_dir, f) for f in files]
|
||||
else:
|
||||
files = [filepath]
|
||||
|
||||
self.log.debug("Add directories to 'cleanupEmptyDir': {}".format(staging_dir))
|
||||
instance.context.data["cleanupEmptyDirs"].append(staging_dir)
|
||||
|
||||
self.log.debug("Add files to 'cleanupFullPaths': {}".format(files))
|
||||
instance.context.data["cleanupFullPaths"] += files
|
||||
|
||||
def get_filepath(self, node):
|
||||
# Get sop path
|
||||
node_type = node.type().name()
|
||||
filepath = None
|
||||
|
|
@ -55,11 +71,10 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin,
|
|||
filepath = node.evalParm("filename")
|
||||
|
||||
elif node_type == "ifd":
|
||||
filepath = node.evalParm("vm_picture")
|
||||
# vm_picture is empty when mantra node is
|
||||
# used to export .ifd files only.
|
||||
if not filepath:
|
||||
if node.evalParm("soho_outputmode"):
|
||||
filepath = node.evalParm("soho_diskfile")
|
||||
else:
|
||||
filepath = node.evalParm("vm_picture")
|
||||
|
||||
elif node_type == "Redshift_Proxy_Output":
|
||||
filepath = node.evalParm("RS_archive_file")
|
||||
|
|
@ -80,11 +95,10 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin,
|
|||
filepath = node.evalParm("picture")
|
||||
|
||||
elif node_type == "arnold":
|
||||
filepath = node.evalParm("ar_picture")
|
||||
# ar_picture is empty when arnold node is
|
||||
# used to export .ass files only.
|
||||
if not filepath:
|
||||
if node.evalParm("ar_ass_export_enable"):
|
||||
filepath = node.evalParm("ar_ass_file")
|
||||
else:
|
||||
filepath = node.evalParm("ar_picture")
|
||||
|
||||
elif node_type == "vray_renderer":
|
||||
filepath = node.evalParm("SettingsOutput_img_file_path")
|
||||
|
|
@ -94,11 +108,5 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin,
|
|||
"ROP node type '{}' is not supported for cleaning up."
|
||||
.format(node_type)
|
||||
)
|
||||
return
|
||||
|
||||
if not filepath:
|
||||
self.log.warning("No filepath value to collect.")
|
||||
return
|
||||
filepath = os.path.dirname(filepath)
|
||||
self.log.debug("Add to clean up list: {}".format(filepath))
|
||||
instance.context.data["cleanupFullPaths"].append(filepath)
|
||||
|
||||
return filepath
|
||||
|
|
@ -49,9 +49,9 @@ class PublishPluginsModel(BaseSettingsModel):
|
|||
default_factory=CollectChunkSizeModel,
|
||||
title="Collect Chunk Size."
|
||||
)
|
||||
CollectStagingDirsForCleaningUp:BasicValidateModel = SettingsField(
|
||||
CollectFilesForCleaningUp:BasicValidateModel = SettingsField(
|
||||
default_factory=BasicValidateModel,
|
||||
title="Collect Staging Directories For Cleaning Up."
|
||||
title="Collect Files For Cleaning Up."
|
||||
)
|
||||
ValidateContainers: BasicValidateModel = SettingsField(
|
||||
default_factory=BasicValidateModel,
|
||||
|
|
@ -83,7 +83,7 @@ DEFAULT_HOUDINI_PUBLISH_SETTINGS = {
|
|||
"optional": True,
|
||||
"chunk_size": 999999
|
||||
},
|
||||
"CollectStagingDirsForCleaningUp": {
|
||||
"CollectFilesForCleaningUp": {
|
||||
"enabled": False,
|
||||
"optional": True,
|
||||
"active": True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue