From ddb6ae8a5a38e2a408a701c47bc5484c485dbbd7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 5 Jan 2023 12:25:55 +0800 Subject: [PATCH] import reference during publish --- .../plugins/publish/extract_import_reference.py | 16 ++++++---------- .../modules/deadline/abstract_submit_deadline.py | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_import_reference.py b/openpype/hosts/maya/plugins/publish/extract_import_reference.py index ce284d16fb..51c82dde92 100644 --- a/openpype/hosts/maya/plugins/publish/extract_import_reference.py +++ b/openpype/hosts/maya/plugins/publish/extract_import_reference.py @@ -105,17 +105,13 @@ print("*** Done") # can't use TemporaryNamedFile as that can't be opened in another # process until handles are closed by context manager. with tempfile.TemporaryDirectory() as tmp_dir_name: - tmp_file_name = os.path.join(tmp_dir_name, "import_ref.py") - tmp = open(tmp_file_name, "w+t") - subprocess_args = [ - mayapy_exe, - tmp_file_name - ] - self.log.info("Using temp file: {}".format(tmp.name)) - try: + tmp_script_path = os.path.join(tmp_dir_name, "import_ref.py") + self.log.info("Using script file: {}".format(tmp_script_path)) + with open(tmp_script_path, "wt") as tmp: tmp.write(script) - tmp.close() - run_subprocess(subprocess_args) + + try: + run_subprocess([mayapy_exe, tmp_script_path]) except Exception: self.log.error("Import reference failed", exc_info=True) raise diff --git a/openpype/modules/deadline/abstract_submit_deadline.py b/openpype/modules/deadline/abstract_submit_deadline.py index 909a5871e3..155a647ff6 100644 --- a/openpype/modules/deadline/abstract_submit_deadline.py +++ b/openpype/modules/deadline/abstract_submit_deadline.py @@ -525,9 +525,9 @@ class AbstractSubmitDeadline(pyblish.api.InstancePlugin): # determine published path from Anatomy. template_data = workfile_instance.data.get("anatomyData") if self.import_reference: - rep = workfile_instance.data.get("representations")[1] + rep = workfile_instance.data["representations"][1] else: - rep = workfile_instance.data.get("representations")[0] + rep = workfile_instance.data["representations"][0] template_data["representation"] = rep.get("name") template_data["ext"] = rep.get("ext") template_data["comment"] = None