raise PublishXmlValidationError in validate workfile project name

This commit is contained in:
iLLiCiTiT 2021-12-22 14:13:03 +01:00
parent 4c11ae83ee
commit b9763e0e21
2 changed files with 45 additions and 12 deletions

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Project name</title>
<description>## Your scene is from different project
It is not possible to publish into project "{workfile_project_name}" when TVPaint was opened with project "{env_project_name}" in context.
### How to repair?
If the workfile belongs to project "{env_project_name}" then use Workfiles tool to resave it.
Otherwise close TVPaint and launch it again from project you want to publish in.
</description>
<detail>
### How this could happend?
You've opened workfile from different project. You've opened TVPaint on a task from "{env_project_name}" then you've opened TVPaint again on task from "{workfile_project_name}" without closing the TVPaint. Because TVPaint can run only once the project didn't change.
### Why it is important?
Because project may affect how TVPaint works or change publishing behavior it is dangerous to allow change project context in many ways. For example publishing will not run as expected.
</detail>
</error>
</root>

View file

@ -1,5 +1,6 @@
import os
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
class ValidateWorkfileProjectName(pyblish.api.ContextPlugin):
@ -31,15 +32,23 @@ class ValidateWorkfileProjectName(pyblish.api.ContextPlugin):
return
# Raise an error
raise AssertionError((
# Short message
"Workfile from different Project ({})."
# Description what's wrong
" It is not possible to publish when TVPaint was launched in"
"context of different project. Current context project is \"{}\"."
" Launch TVPaint in context of project \"{}\" and then publish."
).format(
workfile_project_name,
env_project_name,
workfile_project_name,
))
raise AssertionError(
self,
(
# Short message
"Workfile from different Project ({})."
# Description what's wrong
" It is not possible to publish when TVPaint was launched in"
"context of different project. Current context project is"
" \"{}\". Launch TVPaint in context of project \"{}\""
" and then publish."
).format(
workfile_project_name,
env_project_name,
workfile_project_name,
),
formatting_data={
"workfile_project_name": workfile_project_name,
"expected_project_name": env_project_name
}
)