From 97404abf43adc4ebb38afa1e93403e7d16776b97 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 8 Dec 2021 19:00:12 +0100 Subject: [PATCH 01/10] OP-2053 - added check of installed extension for PS --- .../publish/collect_extension_version.py | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 openpype/hosts/photoshop/plugins/publish/collect_extension_version.py diff --git a/openpype/hosts/photoshop/plugins/publish/collect_extension_version.py b/openpype/hosts/photoshop/plugins/publish/collect_extension_version.py new file mode 100644 index 00000000000..f07ff0b0ff7 --- /dev/null +++ b/openpype/hosts/photoshop/plugins/publish/collect_extension_version.py @@ -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) From 5dc2fd05885718cb6c90083f14f60de18cc2c828 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 8 Dec 2021 19:00:44 +0100 Subject: [PATCH 02/10] OP-2053 - bump down order of collector for current file It depends on valid extension --- .../hosts/photoshop/plugins/publish/collect_current_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/photoshop/plugins/publish/collect_current_file.py b/openpype/hosts/photoshop/plugins/publish/collect_current_file.py index 3cc3e3f636c..4d4829555ec 100644 --- a/openpype/hosts/photoshop/plugins/publish/collect_current_file.py +++ b/openpype/hosts/photoshop/plugins/publish/collect_current_file.py @@ -8,7 +8,7 @@ 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 = ["photoshop"] From 2673b587731576c30b26f6ec045c3cbff91f0fa3 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 9 Dec 2021 14:01:28 +0100 Subject: [PATCH 03/10] 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 b59ff41a0eb..51f6f5c8448 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 @@ 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 00000000000..3352fd21f0e --- /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) From a80ed0deecc0440fcbc779d4c855f5c6713db958 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 9 Dec 2021 14:25:24 +0100 Subject: [PATCH 04/10] OP-2053 - Hound --- openpype/hosts/aftereffects/plugins/publish/closeAE.py | 2 -- .../hosts/aftereffects/test_publish_in_aftereffects.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/openpype/hosts/aftereffects/plugins/publish/closeAE.py b/openpype/hosts/aftereffects/plugins/publish/closeAE.py index e6e96234743..21bedf0125d 100644 --- a/openpype/hosts/aftereffects/plugins/publish/closeAE.py +++ b/openpype/hosts/aftereffects/plugins/publish/closeAE.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- """Close AE after publish. For Webpublishing only.""" -import os - import pyblish.api from avalon import aftereffects diff --git a/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py b/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py index 3d1fa8f804d..e0f6b3e48e0 100644 --- a/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py +++ b/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py @@ -92,7 +92,7 @@ def test_db_asserts(self, dbcon, publish_finished): "Not expected no of representations" assert 1 == dbcon.count_documents({"type": "representation", - "context.subset": "imageMainBackgroundcopy", #noqa E501 + "context.subset": "imageMainBackgroundcopy", # noqa E501 "context.ext": "png"}), \ "Not expected no of representations with ext 'png'" From 148bb47b7d2c2ad366b2271a1c6916016651fdb2 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 14 Dec 2021 10:54:10 +0100 Subject: [PATCH 05/10] OP-2053 - allow injection of AVALON_DB env var as a db --- start.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/start.py b/start.py index 0f7e82071d7..10b81bc7256 100644 --- a/start.py +++ b/start.py @@ -339,13 +339,14 @@ def set_avalon_environments(): os.environ.get("AVALON_MONGO") or os.environ["OPENPYPE_MONGO"] ) + avalon_db = os.environ.get("AVALON_DB") or "avalon" # for tests os.environ.update({ # Mongo url (use same as OpenPype has) "AVALON_MONGO": avalon_mongo_url, "AVALON_SCHEMA": schema_path, # Mongo DB name where avalon docs are stored - "AVALON_DB": "avalon", + "AVALON_DB": avalon_db, # Name of config "AVALON_CONFIG": "openpype", "AVALON_LABEL": "OpenPype" From 8739dd9f05e7f70dddd388da2de0b7efd4456832 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 14 Dec 2021 11:13:02 +0100 Subject: [PATCH 06/10] OP-2053 - fix counts in db_asserts --- .../hosts/aftereffects/test_publish_in_aftereffects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py b/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py index e0f6b3e48e0..ec0280e7c6a 100644 --- a/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py +++ b/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py @@ -68,7 +68,7 @@ def startup_scripts(self, monkeypatch_session, download_test_data): 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"}), \ + assert 2 == dbcon.count_documents({"type": "version"}), \ "Not expected no of versions" assert 0 == dbcon.count_documents({"type": "version", @@ -88,7 +88,7 @@ def test_db_asserts(self, dbcon, publish_finished): "name": "reviewTesttask"}), \ "reviewTesttask subset must be present" - assert 6 == dbcon.count_documents({"type": "representation"}), \ + assert 4 == dbcon.count_documents({"type": "representation"}), \ "Not expected no of representations" assert 1 == dbcon.count_documents({"type": "representation", From 02717fac4eaaf5dbd17ddcf86e59bc58b136a8ff Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 14 Dec 2021 11:15:51 +0100 Subject: [PATCH 07/10] Update error msg format Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../plugins/publish/collect_extension_version.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py b/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py index 3352fd21f0e..4e74252043a 100644 --- a/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py +++ b/openpype/hosts/aftereffects/plugins/publish/collect_extension_version.py @@ -48,9 +48,9 @@ def process(self, context): 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." + msg = ( + "Expected version '{}' found '{}'\n Please update" + " your installed extension, it might not work properly." + ).format(expected_version, installed_version) raise ValueError(msg) From aa232b43268cd38a0162eb6af6d50a8d4b1d998c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 14 Dec 2021 11:13:02 +0100 Subject: [PATCH 08/10] OP-2053 - fix counts in db_asserts --- .../hosts/aftereffects/test_publish_in_aftereffects.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py b/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py index e0f6b3e48e0..c3ca9aa9d23 100644 --- a/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py +++ b/tests/integration/hosts/aftereffects/test_publish_in_aftereffects.py @@ -68,7 +68,7 @@ def startup_scripts(self, monkeypatch_session, download_test_data): 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"}), \ + assert 2 == dbcon.count_documents({"type": "version"}), \ "Not expected no of versions" assert 0 == dbcon.count_documents({"type": "version", @@ -81,18 +81,18 @@ def test_db_asserts(self, dbcon, publish_finished): "modelMain subset must be present" assert 1 == dbcon.count_documents({"type": "subset", - "name": "workfileTesttask"}), \ + "name": "workfileTest_task"}), \ "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"}), \ + assert 4 == dbcon.count_documents({"type": "representation"}), \ "Not expected no of representations" assert 1 == dbcon.count_documents({"type": "representation", - "context.subset": "imageMainBackgroundcopy", # noqa E501 + "context.subset": "renderTestTaskDefault", # noqa E501 "context.ext": "png"}), \ "Not expected no of representations with ext 'png'" From 450dbf3fd25225b4d94a6f92f6404ccb5a0c80c3 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 14 Dec 2021 15:29:42 +0100 Subject: [PATCH 09/10] OP-2053 - fix PS after merge --- .../photoshop/test_publish_in_photoshop.py | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/tests/integration/hosts/photoshop/test_publish_in_photoshop.py b/tests/integration/hosts/photoshop/test_publish_in_photoshop.py index b52af480091..f7bedf60699 100644 --- a/tests/integration/hosts/photoshop/test_publish_in_photoshop.py +++ b/tests/integration/hosts/photoshop/test_publish_in_photoshop.py @@ -44,32 +44,6 @@ class TestPublishInPhotoshop(PhotoshopTestClass): 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.psd") - 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.psd") - shutil.copy(src_path, dest_path) - - yield dest_path - - @pytest.fixture(scope="module") - def startup_scripts(self, monkeypatch_session, download_test_data): - """Points Maya to userSetup file from input data""" - pass def test_db_asserts(self, dbcon, publish_finished): """Host and input data dependent expected results in DB.""" From 2c66a1eab2527a34029fc639fc475efa2dc77896 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 14 Dec 2021 15:31:03 +0100 Subject: [PATCH 10/10] OP-2053 - fix PS after merge --- tests/integration/hosts/photoshop/test_publish_in_photoshop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/hosts/photoshop/test_publish_in_photoshop.py b/tests/integration/hosts/photoshop/test_publish_in_photoshop.py index f7bedf60699..32053cd9d4f 100644 --- a/tests/integration/hosts/photoshop/test_publish_in_photoshop.py +++ b/tests/integration/hosts/photoshop/test_publish_in_photoshop.py @@ -37,7 +37,7 @@ class TestPublishInPhotoshop(PhotoshopTestClass): ] APP = "photoshop" - # keep empty to locate latest installed variant or explicit + # keep empty to locate latest installed variant or explicit APP_VARIANT = "" APP_NAME = "{}/{}".format(APP, APP_VARIANT)