Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5476 from ynput/enhancement/OP-6394_project-creat…
Browse files Browse the repository at this point in the history
…ion-in-temp-location
  • Loading branch information
antirotor authored Sep 4, 2023
2 parents 1a02a05 + 92000bc commit 424d20a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions openpype/hosts/unreal/hooks/pre_workfile_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""Hook to launch Unreal and prepare projects."""
import os
import copy
import shutil
import tempfile
from pathlib import Path

from qtpy import QtCore
Expand Down Expand Up @@ -224,10 +226,24 @@ def execute(self):
project_file = project_path / unreal_project_filename

if not project_file.is_file():
self.exec_ue_project_gen(engine_version,
unreal_project_name,
engine_path,
project_path)
with tempfile.TemporaryDirectory() as temp_dir:
self.exec_ue_project_gen(engine_version,
unreal_project_name,
engine_path,
Path(temp_dir))
try:
self.log.info((
f"Moving from {temp_dir} to "
f"{project_path.as_posix()}"
))
shutil.copytree(
temp_dir, project_path, dirs_exist_ok=True)

except shutil.Error as e:
raise ApplicationLaunchFailed((
f"{self.signature} Cannot copy directory {temp_dir} "
f"to {project_path.as_posix()} - {e}"
)) from e

self.launch_context.env["AYON_UNREAL_VERSION"] = engine_version
# Append project file to launch arguments
Expand Down

0 comments on commit 424d20a

Please sign in to comment.