This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Add validator to check correct version of extension for PS and AE #2387
Merged
kalisp
merged 17 commits into
develop
from
feature/OP-2053_Add-validator-to-check-correct-version-of-extension-for-PS-and-AE
Dec 14, 2021
Merged
Changes from 20 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
97404ab
OP-2053 - added check of installed extension for PS
kalisp 5dc2fd0
OP-2053 - bump down order of collector for current file
kalisp 2a540cd
Merge branch 'feature/OP-2019_Create-test-publish-class-for-AE' into …
kalisp 2673b58
OP-2053 - added possibility to check installed extension version
kalisp a80ed0d
OP-2053 - Hound
kalisp 148bb47
OP-2053 - allow injection of AVALON_DB env var as a db
kalisp 8739dd9
OP-2053 - fix counts in db_asserts
kalisp 02717fa
Update error msg format
kalisp aa232b4
OP-2053 - fix counts in db_asserts
kalisp b2644d3
Merge remote-tracking branch 'origin/feature/OP-2053_Add-validator-to…
kalisp 621118c
Merge remote-tracking branch 'origin/feature/OP-2053_Add-validator-to…
kalisp 61bf279
Merge branch 'develop' into feature/OP-2053_Add-validator-to-check-co…
kalisp b97d79d
Merge branch 'develop' into feature/OP-2053_Add-validator-to-check-co…
kalisp 1cbcdba
OP-2053 - merge develop
kalisp 0cd9502
Merge remote-tracking branch 'origin/feature/OP-2053_Add-validator-to…
kalisp 450dbf3
OP-2053 - fix PS after merge
kalisp 2c66a1e
OP-2053 - fix PS after merge
kalisp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Close AE after publish. For Webpublishing only.""" | ||
import pyblish.api | ||
|
||
from avalon import aftereffects | ||
|
||
|
||
class CloseAE(pyblish.api.ContextPlugin): | ||
"""Close AE after publish. For Webpublishing only. | ||
""" | ||
|
||
order = pyblish.api.IntegratorOrder + 14 | ||
label = "Close AE" | ||
optional = True | ||
active = True | ||
|
||
hosts = ["aftereffects"] | ||
targets = ["remotepublish"] | ||
|
||
def process(self, context): | ||
self.log.info("CloseAE") | ||
|
||
stub = aftereffects.stub() | ||
self.log.info("Shutting down AE") | ||
stub.save() | ||
stub.close() | ||
self.log.info("AE closed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import re | ||
import pyblish.api | ||
|
||
from avalon import aftereffects | ||
|
||
|
||
class CollectExtensionVersion(pyblish.api.ContextPlugin): | ||
""" Pulls and compares version of installed extension. | ||
|
||
It is recommended to use same extension as in provided Openpype code. | ||
|
||
Please use Anastasiy’s Extension Manager or ZXPInstaller to update | ||
extension in case of an error. | ||
|
||
You can locate extension.zxp in your installed Openpype code in | ||
`repos/avalon-core/avalon/aftereffects` | ||
""" | ||
# This technically should be a validator, but other collectors might be | ||
# impacted with usage of obsolete extension, so collector that runs first | ||
# was chosen | ||
order = pyblish.api.CollectorOrder - 0.5 | ||
label = "Collect extension version" | ||
hosts = ["aftereffects"] | ||
|
||
optional = True | ||
active = True | ||
|
||
def process(self, context): | ||
installed_version = aftereffects.stub().get_extension_version() | ||
|
||
if not installed_version: | ||
raise ValueError("Unknown version, probably old extension") | ||
|
||
manifest_url = os.path.join(os.path.dirname(aftereffects.__file__), | ||
"extension", "CSXS", "manifest.xml") | ||
|
||
if not os.path.exists(manifest_url): | ||
self.log.debug("Unable to locate extension manifest, not checking") | ||
return | ||
|
||
expected_version = None | ||
with open(manifest_url) as fp: | ||
content = fp.read() | ||
found = re.findall(r'(ExtensionBundleVersion=")([0-9\.]+)(")', | ||
content) | ||
if found: | ||
expected_version = found[0][1] | ||
|
||
if expected_version != installed_version: | ||
msg = "Expected version '{}' found '{}'\n".format( | ||
expected_version, installed_version) | ||
msg += "Please update your installed extension, it might not work " | ||
msg += "properly." | ||
kalisp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
raise ValueError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
openpype/hosts/photoshop/plugins/publish/collect_extension_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
import re | ||
import pyblish.api | ||
|
||
from avalon import photoshop | ||
|
||
|
||
class CollectExtensionVersion(pyblish.api.ContextPlugin): | ||
""" Pulls and compares version of installed extension. | ||
|
||
It is recommended to use same extension as in provided Openpype code. | ||
|
||
Please use Anastasiy’s Extension Manager or ZXPInstaller to update | ||
extension in case of an error. | ||
|
||
You can locate extension.zxp in your installed Openpype code in | ||
`repos/avalon-core/avalon/photoshop` | ||
""" | ||
# This technically should be a validator, but other collectors might be | ||
# impacted with usage of obsolete extension, so collector that runs first | ||
# was chosen | ||
order = pyblish.api.CollectorOrder - 0.5 | ||
label = "Collect extension version" | ||
hosts = ["photoshop"] | ||
|
||
optional = True | ||
active = True | ||
|
||
def process(self, context): | ||
installed_version = photoshop.stub().get_extension_version() | ||
|
||
if not installed_version: | ||
raise ValueError("Unknown version, probably old extension") | ||
|
||
manifest_url = os.path.join(os.path.dirname(photoshop.__file__), | ||
"extension", "CSXS", "manifest.xml") | ||
|
||
if not os.path.exists(manifest_url): | ||
self.log.debug("Unable to locate extension manifest, not checking") | ||
return | ||
|
||
expected_version = None | ||
with open(manifest_url) as fp: | ||
content = fp.read() | ||
|
||
found = re.findall(r'(ExtensionBundleVersion=")([0-10\.]+)(")', | ||
content) | ||
if found: | ||
expected_version = found[0][1] | ||
|
||
if expected_version != installed_version: | ||
msg = "Expected version '{}' found '{}'\n".format( | ||
expected_version, installed_version) | ||
msg += "Please update your installed extension, it might not work " | ||
msg += "properly." | ||
|
||
raise ValueError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import pytest | ||
import os | ||
import shutil | ||
|
||
from tests.lib.testing_classes import PublishTest | ||
|
||
|
||
class TestPublishInAfterEffects(PublishTest): | ||
"""Basic test case for publishing in AfterEffects | ||
|
||
Uses generic TestCase to prepare fixtures for test data, testing DBs, | ||
env vars. | ||
|
||
Opens AfterEffects, run publish on prepared workile. | ||
|
||
Test zip file sets 3 required env vars: | ||
- HEADLESS_PUBLISH - this triggers publish immediately app is open | ||
- IS_TEST - this differentiate between regular webpublish | ||
- PYBLISH_TARGETS | ||
|
||
Then checks content of DB (if subset, version, representations were | ||
created. | ||
Checks tmp folder if all expected files were published. | ||
|
||
""" | ||
PERSIST = True | ||
|
||
TEST_FILES = [ | ||
("1c8261CmHwyMgS-g7S4xL5epAp0jCBmhf", | ||
"test_aftereffects_publish.zip", | ||
"") | ||
] | ||
|
||
APP = "aftereffects" | ||
APP_VARIANT = "2022" | ||
|
||
APP_NAME = "{}/{}".format(APP, APP_VARIANT) | ||
|
||
TIMEOUT = 120 # publish timeout | ||
|
||
@pytest.fixture(scope="module") | ||
def last_workfile_path(self, download_test_data): | ||
"""Get last_workfile_path from source data. | ||
|
||
Maya expects workfile in proper folder, so copy is done first. | ||
""" | ||
src_path = os.path.join(download_test_data, | ||
"input", | ||
"workfile", | ||
"test_project_test_asset_TestTask_v001.aep") | ||
dest_folder = os.path.join(download_test_data, | ||
self.PROJECT, | ||
self.ASSET, | ||
"work", | ||
self.TASK) | ||
os.makedirs(dest_folder) | ||
dest_path = os.path.join(dest_folder, | ||
"test_project_test_asset_TestTask_v001.aep") | ||
shutil.copy(src_path, dest_path) | ||
|
||
yield dest_path | ||
|
||
@pytest.fixture(scope="module") | ||
def startup_scripts(self, monkeypatch_session, download_test_data): | ||
"""Points AfterEffects to userSetup file from input data""" | ||
pass | ||
|
||
def test_db_asserts(self, dbcon, publish_finished): | ||
"""Host and input data dependent expected results in DB.""" | ||
print("test_db_asserts") | ||
assert 3 == dbcon.count_documents({"type": "version"}), \ | ||
"Not expected no of versions" | ||
|
||
assert 0 == dbcon.count_documents({"type": "version", | ||
"name": {"$ne": 1}}), \ | ||
"Only versions with 1 expected" | ||
|
||
assert 1 == dbcon.count_documents({"type": "subset", | ||
"name": "imageMainBackgroundcopy" | ||
}), \ | ||
"modelMain subset must be present" | ||
|
||
assert 1 == dbcon.count_documents({"type": "subset", | ||
"name": "workfileTesttask"}), \ | ||
"workfileTesttask subset must be present" | ||
|
||
assert 1 == dbcon.count_documents({"type": "subset", | ||
"name": "reviewTesttask"}), \ | ||
"reviewTesttask subset must be present" | ||
|
||
assert 6 == dbcon.count_documents({"type": "representation"}), \ | ||
"Not expected no of representations" | ||
|
||
assert 1 == dbcon.count_documents({"type": "representation", | ||
"context.subset": "imageMainBackgroundcopy", # noqa E501 | ||
"context.ext": "png"}), \ | ||
"Not expected no of representations with ext 'png'" | ||
|
||
|
||
if __name__ == "__main__": | ||
test_case = TestPublishInAfterEffects() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in a validator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but "It should be technically validator, but it could miss some failing collectors which would result in non understandable errors."