Skip to content
Snippets Groups Projects
Commit 6925935c authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Check if files exist before attempting to remove

parent 8ac28ec9
Branches
No related tags found
No related merge requests found
......@@ -253,7 +253,10 @@ for timestep in timesteps:
# Merge the WARNING_STATUS and WHS variables into one GeoTIFF file with two bands.
# The WARNING_STATUS should always be band #1
# We must delete the GeoTIFF file before merging
run_command(command=f'rm {result_tif_path}result_*{file_date}*.tif')
existing_result_files_for_date = f"{result_tif_path}result_*{file_date}*.tif"
files = glob.glob(existing_result_files_for_date)
if files:
run_command(command=f'rm {existing_result_files_for_date}')
with open("/dev/null", "w") as devnull:
run_command(command=f'gdal_translate -ot Int16 -of GTiff NETCDF:"{tmpfile_path}result_{file_date}.nc":WARNING_STATUS {tmpfile_path}result_WARNING_STATUS_{file_date}_lcc.tif', stdout=devnull)
run_command(command=f'gdal_translate -ot Float32 -of GTiff NETCDF:"{tmpfile_path}result_{file_date}.nc":WHS {tmpfile_path}result_{file_date}_lcc.tif', stdout=devnull)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment