Skip to content

Commit

Permalink
FIX: Design save project mkdir (#4868)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Ciurana <[email protected]>
Co-authored-by: Alex Ciurana <[email protected]>
Co-authored-by: Kathy Pippert <[email protected]>
  • Loading branch information
4 people authored Jul 2, 2024
1 parent d51fe51 commit c4cde69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,18 @@ def test_41_desktop_reference_counting(self, desktop):
hfss.set_active_design(hfss.design_name)
assert desktop._connected_app_instances == num_references + 1
assert desktop._connected_app_instances == num_references

def test_42_save_project_with_file_name(self):
# Save into path with existing parent dir
self.aedtapp.create_new_project("Test")
new_project = os.path.join(self.local_scratch.path, "new.aedt")
assert os.path.exists(self.local_scratch.path)
self.aedtapp.save_project(file_name=new_project)
assert os.path.isfile(new_project)

# Save into path with non-existing parent dir
new_parent_dir = os.path.join(self.local_scratch.path, "new_dir")
new_project = os.path.join(new_parent_dir, "new_2.aedt")
assert not os.path.exists(new_parent_dir)
self.aedtapp.save_project(file_name=new_project)
assert os.path.isfile(new_project)
9 changes: 6 additions & 3 deletions pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -3751,9 +3751,12 @@ def save_project(self, file_name=None, overwrite=True, refresh_ids=False):
>>> oProject.Save
>>> oProject.SaveAs
"""
if file_name and not os.path.exists(os.path.dirname(file_name)):
os.makedirs(os.path.dirname(file_name))
elif file_name:
if file_name:
file_parent_dir = os.path.dirname(os.path.normpath(file_name))
if settings.remote_rpc_session and not settings.remote_rpc_session.filemanager.pathexists(file_parent_dir):
settings.remote_rpc_session.filemanager.makedirs(file_parent_dir)
elif not settings.remote_rpc_session and not os.path.isdir(file_parent_dir):
os.makedirs(file_parent_dir)
self.oproject.SaveAs(file_name, overwrite)
self._add_handler()
else:
Expand Down

0 comments on commit c4cde69

Please sign in to comment.