OP-4504 - changed to XMLPublishError

This commit is contained in:
Petr Kalis 2022-12-15 13:15:14 +01:00
parent a3969f8d1a
commit ee58c0ce48
2 changed files with 44 additions and 8 deletions

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Source directory not collected</title>
<description>
## Source directory not collected
Instance is marked for in place publishing. Its 'originalDirname' must be collected. Contact OP developer to modify collector.
</description>
<detail>
### __Detailed Info__ (optional)
In place publishing uses source directory and file name in resulting path and file name of published item. For this instance
all required metadata weren't filled. This is not recoverable error, unless instance itself is removed.
Collector for this instance must be updated for instance to be published.
</detail>
</error>
<error id="not_in_dir">
<title>Source file not in project dir</title>
<description>
## Source file not in project dir
Path '{original_dirname}' not in project folder. Please publish from inside of project folder.
### How to repair?
Restart publish after you moved source file into project directory.
</description>
</error>
</root>

View file

@ -1,7 +1,7 @@
import pyblish.api
from openpype.pipeline.publish import ValidateContentsOrder
from openpype.pipeline.publish import (
KnownPublishError,
PublishXmlValidationError,
get_publish_template_name,
)
@ -35,20 +35,25 @@ class ValidatePublishDir(pyblish.api.InstancePlugin):
original_dirname = instance.data.get("originalDirname")
if not original_dirname:
raise KnownPublishError(
raise PublishXmlValidationError(
self,
"Instance meant for in place publishing."
" Its 'originalDirname' must be collected."
" Contact OP developer to modify collector.")
" Contact OP developer to modify collector."
)
anatomy = instance.context.data["anatomy"]
success, _ = anatomy.find_root_template_from_path(original_dirname)
self.log.info(_)
formatting_data = {
"original_dirname": original_dirname,
}
msg = "Path '{}' not in project folder.".format(original_dirname) + \
" Please publish from inside of project folder."
if not success:
raise PublishValidationError(
"Path '{}' not in project folder.".format(original_dirname) +
" Please publish from inside of project folder."
)
raise PublishXmlValidationError(self, msg, key="not_in_dir",
formatting_data=formatting_data)
def _get_template_name_from_instance(self, instance):
project_name = instance.context.data["projectName"]