Skip to content

Commit

Permalink
Merge pull request #29 from quadproduction/enhancement/add-validate-f…
Browse files Browse the repository at this point in the history
…older-creation

Force render folder creation from Local
  • Loading branch information
BenSouchet authored Dec 29, 2023
2 parents f9d2c1f + 24d3b3d commit 40c393d
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from pyblish import api
from openpype.pipeline.publish import ValidateContentsOrder
from openpype.pipeline.publish.lib import get_publish_template_name
import os
import copy


class ValidateRenderFolderCreation(api.InstancePlugin):
"""Validate Render Folder Creation"""

order = ValidateContentsOrder
hosts = ["maya"]
families = ["renderlayer", "renderlocal"]
label = "Validate Render Folder Creation"
optional = True

def process(self, instance):
"""The aim is to create the publish folder directly from the user machine and
not from the renderfarm.
:param context: The Pyblish context.
:type context: pyblish.api.Context
"""
# Get the context data
anatomy = instance.context.data["anatomy"]
template_data = copy.deepcopy(instance.data["anatomyData"])
# We force the family as 'render' (Check ValidatePublishDir() Plugin)
template_data["family"] = "render"
# Recover the publish template
publish_templates = anatomy.templates_obj["publish"]
# Generate the template
publish_folder = publish_templates["folder"].format_strict(template_data)
publish_folder = os.path.normpath(publish_folder)

self.log.debug("publishDir: \"{}\"".format(publish_folder))
# Force creation of the folder
if not os.path.exists(publish_folder):
os.makedirs(publish_folder)

0 comments on commit 40c393d

Please sign in to comment.