import reference during publish

This commit is contained in:
Kayla Man 2023-01-05 12:25:55 +08:00
parent df62f315cc
commit ddb6ae8a5a
2 changed files with 8 additions and 12 deletions

View file

@ -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

View file

@ -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