From e48f541dff89f04f33168b98cba7d9f19797b33f Mon Sep 17 00:00:00 2001 From: beckermr Date: Fri, 26 May 2023 08:46:09 -0500 Subject: [PATCH] BUG make sure to delete files properly and test for errors --- eastlake/steps/delete_meds.py | 23 +++++++++++++---------- eastlake/steps/delete_sources.py | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/eastlake/steps/delete_meds.py b/eastlake/steps/delete_meds.py index f0d5c58..ffb56bb 100644 --- a/eastlake/steps/delete_meds.py +++ b/eastlake/steps/delete_meds.py @@ -26,15 +26,18 @@ def execute(self, stash, new_params=None): if tilename in self.config["save_tilenames"]: continue - # Get meds filenames - meds_files = stash.get_filepaths("meds_files", tilename) - for m in meds_files: - self.logger.error("removing meds file %s" % m) - os.remove(m) - - meds_files = stash.get_filepaths("pizza_cutter_meds_files", tilename) - for m in meds_files: - self.logger.error("removing pizza-cutter meds file %s" % m) - os.remove(m) + meds_files = stash.get_filepaths("meds_files", tilename, keyerror=False) + if meds_files is not None: + for m in meds_files: + if os.path.isfile(m): + self.logger.error("removing meds file %s" % m) + os.remove(m) + + meds_files = stash.get_filepaths("pizza_cutter_meds_files", tilename, keyerror=False) + if meds_files is not None: + for m in meds_files: + if os.path.isfile(m): + self.logger.error("removing pizza-cutter meds file %s" % m) + os.remove(m) return 0, stash diff --git a/eastlake/steps/delete_sources.py b/eastlake/steps/delete_sources.py index ab9a3d1..6e6e97a 100644 --- a/eastlake/steps/delete_sources.py +++ b/eastlake/steps/delete_sources.py @@ -57,6 +57,7 @@ def execute(self, stash, new_params=None): if (seg_file is not None): if os.path.isfile(seg_file): self.logger.error("removing file %s" % seg_file) + os.remove(seg_file) # Also check for bkg and bkg-rms files bkg_file = coadd_file.replace(".fits", "bkg.fits")