From 0b2ef408f09e27a24ff0cbecd2cc71276c74f53d Mon Sep 17 00:00:00 2001 From: daringli Date: Wed, 29 May 2024 22:06:52 +0200 Subject: [PATCH 1/2] Added a file not found exception handling. --- src/simsopt/mhd/vmec.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/simsopt/mhd/vmec.py b/src/simsopt/mhd/vmec.py index beef7c96e..822815fdb 100644 --- a/src/simsopt/mhd/vmec.py +++ b/src/simsopt/mhd/vmec.py @@ -755,7 +755,11 @@ def run(self): # Delete the previous output file, if desired: for filename in self.files_to_delete: - os.remove(filename) + try: + os.remove(filename) + except FileNotFoundError: + logger.debug('Tried to delete the file {filename} but it was not found') + self.files_to_delete = [] # Record the latest output file to delete if we run again: From a715c0f41579efc982aaf8b4a94fb352ebc199cc Mon Sep 17 00:00:00 2001 From: daringli <731405+daringli@users.noreply.github.com> Date: Wed, 29 May 2024 21:38:33 -0400 Subject: [PATCH 2/2] Fixed missing f in the f-string Thanks to VascoSch92! --- src/simsopt/mhd/vmec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simsopt/mhd/vmec.py b/src/simsopt/mhd/vmec.py index a2e0ce4f9..507c8c9a7 100644 --- a/src/simsopt/mhd/vmec.py +++ b/src/simsopt/mhd/vmec.py @@ -755,7 +755,7 @@ def run(self): try: os.remove(filename) except FileNotFoundError: - logger.debug('Tried to delete the file {filename} but it was not found') + logger.debug(f"Tried to delete the file {filename} but it was not found") self.files_to_delete = []