diff --git a/app/let_it_snow_synthesis.py b/app/let_it_snow_synthesis.py index 0a0846ccbff579f4ea76e5f95efbd5782e82f5e1..9d85946ce0c97ded1eee913d7b17442e2a4311a8 100644 --- a/app/let_it_snow_synthesis.py +++ b/app/let_it_snow_synthesis.py @@ -25,10 +25,12 @@ import sys import json from logging.handlers import RotatingFileHandler -from s2snow.lis_exception import LisConfigurationException +from s2snow.lis_exception import LisConfigurationException, NoSnowProductFound, NoZipFound, NoProductMatchingSynthesis, \ + UnknownPlatform from s2snow.snow_synthesis import compute_snow_synthesis from s2snow.synthesis_config import SynthesisConfig -from s2snow.lis_constant import INPUT_PARAMETER_ERROR, CONFIGURATION_ERROR, TMP_DIR, LOG_FILE +from s2snow.lis_constant import INPUT_PARAMETER_ERROR, CONFIGURATION_ERROR, TMP_DIR, LOG_FILE, NO_SNOW_PRODUCT_FOUND, \ + NO_ZIP_FOUND, NO_PRODUCT_MATCHING_SYNTHESIS, UNKNOWN_PLATFORM from s2snow.parser import create_synthesis_argument_parser @@ -57,6 +59,18 @@ def main(config_file, tile_id, input_products_list, densification_products_list, try: logging.info("Launch snow synthesis computation.") compute_snow_synthesis(config, output_dir, h2_chain_version, product_counter) + except UnknownPlatform as e: + logging.error(e) + return UNKNOWN_PLATFORM + except NoProductMatchingSynthesis as e: + logging.error(e) + return NO_PRODUCT_MATCHING_SYNTHESIS + except NoSnowProductFound as e: + logging.error(e) + return NO_SNOW_PRODUCT_FOUND + except NoZipFound as e: + logging.error(e) + return NO_ZIP_FOUND except Exception as e: logging.error(e) return -1 diff --git a/python/s2snow/lis_constant.py b/python/s2snow/lis_constant.py index 120a7f39c16aeb73f054aa754966a3ed67e2a527..7742509c35c11bb382c72716f480f941b0d40dee 100644 --- a/python/s2snow/lis_constant.py +++ b/python/s2snow/lis_constant.py @@ -110,6 +110,10 @@ OUTPUT_DATES_FILE = "output_dates.txt" INPUT_PARAMETER_ERROR = -2 UNKNOWN_PRODUCT_EXCEPTION = -3 CONFIGURATION_ERROR = -4 +UNKNOWN_PLATFORM = -5 +NO_PRODUCT_MATCHING_SYNTHESIS = -6 +NO_SNOW_PRODUCT_FOUND = -7 +NO_ZIP_FOUND = -8 # Date Time format MUSCATE_DATETIME_FORMAT = "%Y%m%d-%H%M%S-%f" diff --git a/python/s2snow/snow_product.py b/python/s2snow/snow_product.py index 76664a0785630034564781c7240a7f15b6a4e1b6..a3e58d029e709ba0d7ef671260c9d8205024d4c1 100644 --- a/python/s2snow/snow_product.py +++ b/python/s2snow/snow_product.py @@ -59,7 +59,6 @@ class SnowProduct: for root, dirs, files in os.walk(absolute_filename): for file in files: if file.lower().endswith('.zip'): - zip_product = True zip_file = file break else: @@ -86,7 +85,7 @@ class SnowProduct: elif LANDSAT8 in platform and N2A in self.product_name: self.acquisition_date = datetime.strptime(name_splitted[3], LANDSAT_DATETIME_FORMAT) self.tile_id = name_splitted[5] - self.snow_mask = find_files(self.product_path, ".*_SNW_XS.(tif/TIF)") + self.snow_mask = find_files(self.product_path, ".*_SNW_XS.(tif|TIF)") self.metadata_file = find_files(self.product_path, ".*_MTD_ALL.(xml|XML)") elif LIS in platform: self.acquisition_date = datetime.strptime(name_splitted[3], LIS_DATETIME_FORMAT) @@ -119,8 +118,9 @@ class SnowProduct: logging.debug("product_name : " + self.product_name) logging.debug("acquisition_date : " + str(self.acquisition_date)) logging.debug("tile_id : " + self.tile_id) - logging.debug("snow_mask : " + self.snow_mask) - logging.debug("metadata_file : " + self.metadata_file) + logging.debug("snow_mask : " + self.get_snow_mask()) + if self.metadata_file: + logging.debug("metadata_file : " + self.metadata_file) def get_snow_mask(self): if self.snow_mask and op.exists(self.snow_mask): @@ -134,7 +134,7 @@ class SnowProduct: if self.metadata_file and op.exists(self.metadata_file): return self.metadata_file else: - logging.info("The metadata file has not been found.") + logging.warning("The metadata file has not been found.") def extract_from_zipfile(file_name, output_folder):