EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit bd5be4eb authored by Fabian Schindler's avatar Fabian Schindler
Browse files

Raising error when a file would be overridden

parent a329e148
No related branches found
No related tags found
No related merge requests found
import os
from os.path import basename, dirname, join
from math import ceil, floor
import logging
import uuid
import os
from os.path import basename, dirname, join, isfile
import subprocess
from typing import List
from glob import glob
......@@ -21,6 +17,10 @@ def calc_step(source_dir: os.PathLike, target_dir: os.PathLike, formulas: List[d
target_dir,
replace_ext(basename(filename), item.get('output_postfix', '_proc%d' % i) + '.tif', False)
)
# fail if a file would be overridden
# TODO: maybe just log an error
if isfile(target_filename):
raise Exception('Calc output filename %s already exists' % target_filename)
calc_formula(source_dir, item['inputs'], target_filename, item['formula'], item.get('data_type', 'Float32'))
......
......@@ -19,7 +19,7 @@ def output_step(source_dir: os.PathLike, target_dir: os.PathLike, options: dict=
# warp each individual file
warped_files = []
for filename in glob(join(source_dir, '*')):
for filename in glob(join(source_dir, '*.tif')):
target_filename = join(target_dir, replace_ext(basename(filename), extension))
gdal.Warp(target_filename, filename, options=gdal.WarpOptions(
**options
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment