254 introduces an issue where opening an EDB with a corresponding aedt project file will always attempt to delete the project file; this is not always desired e.g. when opening the EDB during an automated test to confirm that earlier actions produced the correct result. At a minimum when an EDB is opened read-only the aedt (and aedt.lock) file(s) should be left in place if they exist.
There is also a bug with the implementation of these deletions: shutil.rmtree cannot be used to delete a file (at least in Python 3.10) as it throws a NonDirectoryException in this case. So currently this is a no-op, but before this is fixed I'd like to open a discussion as above on whether the aedt file should always be deleted or not.
Steps To Reproduce
Run the following script in a virtual environment with both pyaedt and pyedb installed:
from pathlib import Path
import shutil
import tempfile
from pyaedt import Hfss3dLayout
from pyedb import Edb
version = "2024.1"
folder = Path(tempfile.mkdtemp())
aedt_path = folder / "project.aedt"
with Hfss3dLayout(close_on_exit=True, non_graphical=True, specified_version=version) as hfss:
hfss.save_project(aedt_path.as_posix())
assert aedt_path.is_file()
edb_path = aedt_path.with_suffix(".aedb")
assert edb_path.is_dir()
db = Edb(edb_path.as_posix(), edbversion=version, isreadonly=True)
try:
pass
finally:
db.close_edb()
assert aedt_path.is_file()
Before submitting the issue
Description of the bug
254 introduces an issue where opening an EDB with a corresponding aedt project file will always attempt to delete the project file; this is not always desired e.g. when opening the EDB during an automated test to confirm that earlier actions produced the correct result. At a minimum when an EDB is opened read-only the aedt (and aedt.lock) file(s) should be left in place if they exist.
There is also a bug with the implementation of these deletions: shutil.rmtree cannot be used to delete a file (at least in Python 3.10) as it throws a NonDirectoryException in this case. So currently this is a no-op, but before this is fixed I'd like to open a discussion as above on whether the aedt file should always be deleted or not.
Steps To Reproduce
Run the following script in a virtual environment with both pyaedt and pyedb installed:
Initially (with current main branch) there will be no assertion error because https://github.com/ansys/pyedb/blame/d135483cd94cb87d8c27c2ae67de302718430f4b/src/pyedb/dotnet/edb.py#L221 will throw a NonDirectoryException. Changing this line to os.unlink(file) will remove the file but then result in an AssertionError on line 28 of the script.
Which Operating System are you using?
Windows
Which Python version are you using?
3.10
Installed packages