Merge pull request #2138 from pypeclub/bugfix/OP-1063_Stadanlone-publishing-source-files-bugs

This commit is contained in:
Milan Kolar 2021-10-22 16:32:18 +02:00 committed by GitHub
commit 06835d7032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,37 @@
import pyblish.api
import openpype.api
import os
class ValidateSources(pyblish.api.InstancePlugin):
"""Validates source files.
Loops through all 'files' in 'stagingDir' if actually exist. They might
got deleted between starting of SP and now.
"""
order = openpype.api.ValidateContentsOrder
label = "Check source files"
optional = True # only for unforeseeable cases
hosts = ["standalonepublisher"]
def process(self, instance):
self.log.info("instance {}".format(instance.data))
for repr in instance.data["representations"]:
files = []
if isinstance(repr["files"], str):
files.append(repr["files"])
else:
files = list(repr["files"])
for file_name in files:
source_file = os.path.join(repr["stagingDir"],
file_name)
if not os.path.exists(source_file):
raise ValueError("File {} not found".format(source_file))