Skip to content

Commit c4cde69

Browse files
SMoraisAnsysalexciuranaPipKat
authored
FIX: Design save project mkdir (#4868)
Co-authored-by: Alex Ciurana <[email protected]> Co-authored-by: Alex Ciurana <[email protected]> Co-authored-by: Kathy Pippert <[email protected]>
1 parent d51fe51 commit c4cde69

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

_unittest/test_01_Design.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,18 @@ def test_41_desktop_reference_counting(self, desktop):
484484
hfss.set_active_design(hfss.design_name)
485485
assert desktop._connected_app_instances == num_references + 1
486486
assert desktop._connected_app_instances == num_references
487+
488+
def test_42_save_project_with_file_name(self):
489+
# Save into path with existing parent dir
490+
self.aedtapp.create_new_project("Test")
491+
new_project = os.path.join(self.local_scratch.path, "new.aedt")
492+
assert os.path.exists(self.local_scratch.path)
493+
self.aedtapp.save_project(file_name=new_project)
494+
assert os.path.isfile(new_project)
495+
496+
# Save into path with non-existing parent dir
497+
new_parent_dir = os.path.join(self.local_scratch.path, "new_dir")
498+
new_project = os.path.join(new_parent_dir, "new_2.aedt")
499+
assert not os.path.exists(new_parent_dir)
500+
self.aedtapp.save_project(file_name=new_project)
501+
assert os.path.isfile(new_project)

pyaedt/application/Design.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3751,9 +3751,12 @@ def save_project(self, file_name=None, overwrite=True, refresh_ids=False):
37513751
>>> oProject.Save
37523752
>>> oProject.SaveAs
37533753
"""
3754-
if file_name and not os.path.exists(os.path.dirname(file_name)):
3755-
os.makedirs(os.path.dirname(file_name))
3756-
elif file_name:
3754+
if file_name:
3755+
file_parent_dir = os.path.dirname(os.path.normpath(file_name))
3756+
if settings.remote_rpc_session and not settings.remote_rpc_session.filemanager.pathexists(file_parent_dir):
3757+
settings.remote_rpc_session.filemanager.makedirs(file_parent_dir)
3758+
elif not settings.remote_rpc_session and not os.path.isdir(file_parent_dir):
3759+
os.makedirs(file_parent_dir)
37573760
self.oproject.SaveAs(file_name, overwrite)
37583761
self._add_handler()
37593762
else:

0 commit comments

Comments
 (0)