Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/OP-2053_Add-validator-to…
Browse files Browse the repository at this point in the history
…-check-correct-version-of-extension-for-PS-and-AE' into feature/OP-2053_Add-validator-to-check-correct-version-of-extension-for-PS-and-AE
  • Loading branch information
kalisp committed Dec 14, 2021
2 parents 1cbcdba + b97d79d commit 0cd9502
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def process(self, instance):
staging_dir = instance.data["stagingDir"]
self.log.info("staging_dir::{}".format(staging_dir))

stub.render(staging_dir)

# pull file name from Render Queue Output module
render_q = stub.get_render_info()
stub.render(staging_dir)
if not render_q:
raise ValueError("No file extension set in Render Queue")
_, ext = os.path.splitext(os.path.basename(render_q.file_name))
Expand Down
46 changes: 46 additions & 0 deletions openpype/lib/remote_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@
from openpype.lib.plugin_tools import parse_json


def headless_publish(log, close_plugin_name=None, is_test=False):
"""Runs publish in a opened host with a context and closes Python process.
Host is being closed via ClosePS pyblish plugin which triggers 'exit'
method in ConsoleTrayApp.
"""
if not is_test:
dbcon = get_webpublish_conn()
_id = os.environ.get("BATCH_LOG_ID")
if not _id:
log.warning("Unable to store log records, "
"batch will be unfinished!")
return

publish_and_log(dbcon, _id, log, close_plugin_name)
else:
publish(log, close_plugin_name)


def get_webpublish_conn():
"""Get connection to OP 'webpublishes' collection."""
mongo_client = OpenPypeMongoConnection.get_mongo_client()
Expand All @@ -38,6 +57,33 @@ def start_webpublish_log(dbcon, batch_id, user):
}).inserted_id


def publish(log, close_plugin_name=None):
"""Loops through all plugins, logs to console. Used for tests.
Args:
log (OpenPypeLogger)
close_plugin_name (str): name of plugin with responsibility to
close host app
"""
# Error exit as soon as any error occurs.
error_format = "Failed {plugin.__name__}: {error} -- {error.traceback}"

close_plugin = _get_close_plugin(close_plugin_name, log)

for result in pyblish.util.publish_iter():
for record in result["records"]:
log.info("{}: {}".format(
result["plugin"].label, record.msg))

if result["error"]:
log.error(error_format.format(**result))
uninstall()
if close_plugin: # close host app explicitly after error
context = pyblish.api.Context()
close_plugin().process(context)
sys.exit(1)


def publish_and_log(dbcon, _id, log, close_plugin_name=None):
"""Loops through all plugins, logs ok and fails into OP DB.
Expand Down
17 changes: 17 additions & 0 deletions openpype/settings/defaults/system_settings/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,23 @@
"linux": []
},
"environment": {}
},
"2022": {
"enabled": true,
"variant_label": "2022",
"executables": {
"windows": [
"C:\\Program Files\\Adobe\\Adobe After Effects 2022\\Support Files\\AfterFX.exe"
],
"darwin": [],
"linux": []
},
"arguments": {
"windows": [],
"darwin": [],
"linux": []
},
"environment": {}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +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 2 == dbcon.count_documents({"type": "version"}), \
"Not expected no of versions"

Expand Down
38 changes: 37 additions & 1 deletion tests/integration/hosts/photoshop/test_publish_in_photoshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class TestPublishInPhotoshop(PhotoshopTestClass):
- IS_TEST - this differentiate between regular webpublish
- PYBLISH_TARGETS
Always pulls and uses test data from GDrive!
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.
Expand All @@ -30,11 +37,40 @@ 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)

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."""
print("test_db_asserts")
Expand Down

0 comments on commit 0cd9502

Please sign in to comment.