Skip to content

Commit

Permalink
Added some more try catches to try make the windows tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepearson committed Jun 21, 2024
1 parent 132279d commit 4f0ec02
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/geofabrics/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,9 @@ def run(self):
cached_file.unlink()
except (Exception, PermissionError) as caught_exception:
logging.warning(
f"Caught error {caught_exception} "
"during unlink of cached_file. "
"Supressing. You will have to "
"manually delete."
f"Caught error {caught_exception} during unlink of "
"cached_file. Supressing error. You will have to "
f"manually delete {cached_file}."
)
cached_file = temp_file

Expand Down Expand Up @@ -1026,10 +1025,9 @@ def run(self):
cached_file.unlink()
except (Exception, PermissionError) as caught_exception:
logging.warning(
f"Caught error {caught_exception} "
"during unlink of cached_file. "
"Supressing. You will have to "
"manually delete."
f"Caught error {caught_exception} during unlink of "
"cached_file. Supressing error. You will have to "
f"manually delete {cached_file}."
)
cached_file = temp_file

Expand All @@ -1040,8 +1038,14 @@ def run(self):
generator=self.raw_dem,
)
self.logger.info(f"Remove folder {temp_folder} for temporary files")
shutil.rmtree(temp_folder)

try:
shutil.rmtree(temp_folder)
except (Exception, PermissionError) as caught_exception:
logging.warning(
f"Caught error {caught_exception} during rmtree of "
"temp_folder. Supressing error. You will have to "
f"manually delete {temp_folder}."
)
if self.debug:
# Record the parameter used during execution - append to existing
with open(subfolder / "dem_instructions.json", "a") as file_pointer:
Expand Down Expand Up @@ -1436,7 +1440,14 @@ def run(self):
"In processor.RoughnessLengthGenerator - clean folder for "
f"writing temporarily cached netCDF files in {temp_folder}"
)
shutil.rmtree(temp_folder)
try:
shutil.rmtree(temp_folder)
except (Exception, PermissionError) as caught_exception:
logging.warning(
f"Caught error {caught_exception} during rmtree of "
"temp_folder. Supressing error. You will have to "
f"manually delete {temp_folder}."
)

if self.debug:
# Record the parameter used during execution - append to existing
Expand Down

0 comments on commit 4f0ec02

Please sign in to comment.