From 2673b587731576c30b26f6ec045c3cbff91f0fa3 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 9 Dec 2021 14:01:28 +0100 Subject: [PATCH] OP-2053 - added possibility to check installed extension version --- .../plugins/publish/collect_current_file.py | 2 +- .../publish/collect_extension_version.py | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py diff --git a/openpype/hosts/aftereffects/plugins/publish/collect_current_file.py b/openpype/hosts/aftereffects/plugins/publish/collect_current_file.py index b59ff41a0e..51f6f5c844 100644 --- a/openpype/hosts/aftereffects/plugins/publish/collect_current_file.py +++ b/openpype/hosts/aftereffects/plugins/publish/collect_current_file.py @@ -8,7 +8,7 @@ from avalon import aftereffects class CollectCurrentFile(pyblish.api.ContextPlugin): """Inject the current working file into context""" - order = pyblish.api.CollectorOrder - 0.5 + order = pyblish.api.CollectorOrder - 0.49 label = "Current File" hosts = ["aftereffects"] diff --git a/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py b/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py new file mode 100644 index 0000000000..3352fd21f0 --- /dev/null +++ b/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py @@ -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." + + raise ValueError(msg)