def validate_base(self, ignore_no_files=False): """ Validates the configuration and the input files :param bool ignore_no_files: if the extending recipe does not work with files, set this to true to skip the validation check for no files (used in wcs_extract recipe). """ if self.session.get_wcs_service( ) is None or self.session.get_wcs_service() == "": raise RecipeValidationException("No valid wcs endpoint provided") if self.session.get_crs_resolver( ) is None or self.session.get_crs_resolver() == "": raise RecipeValidationException("No valid crs resolver provided") if self.session.get_coverage_id( ) is None or self.session.get_coverage_id() == "": raise RecipeValidationException("No valid coverage id provided") if not FileUtil.check_dir_writable(ConfigManager.tmp_directory): raise RecipeValidationException( "Cannot write to tmp directory '{}'".format( ConfigManager.tmp_directory)) checked_files = [] for file in self.session.get_files(): if FileUtil.validate_file_path(file.get_filepath()): checked_files.append(file) if not ignore_no_files: # If no input file is available, exit wcst_import. FileUtil.validate_input_file_paths(checked_files) self.session.files = checked_files if 'wms_import' not in self.options: self.options['wms_import'] = False else: self.options['wms_import'] = bool(self.options['wms_import']) if 'tiling' not in self.options: self.options['tiling'] = None if 'scale_levels' not in self.options: self.options['scale_levels'] = None if "import_order" in self.options: if self.options['import_order'] != AbstractToCoverageConverter.IMPORT_ORDER_ASCENDING \ and self.options['import_order'] != AbstractToCoverageConverter.IMPORT_ORDER_DESCENDING: error_message = "'import_order' option must be '{}' or '{}', given '{}'.".\ format(AbstractToCoverageConverter.IMPORT_ORDER_ASCENDING, AbstractToCoverageConverter.IMPORT_ORDER_DESCENDING, self.options['import_order']) raise RecipeValidationException(error_message) else: self.options['import_order'] = None
def validate_base(self, ignore_no_files=False): """ Validates the configuration and the input files :param bool ignore_no_files: if the extending recipe does not work with files, set this to true to skip the validation check for no files (used in wcs_extract recipe). """ if self.session.get_wcs_service( ) is None or self.session.get_wcs_service() == "": raise RecipeValidationException("No valid wcs endpoint provided") if self.session.get_crs_resolver( ) is None or self.session.get_crs_resolver() == "": raise RecipeValidationException("No valid crs resolver provided") if self.session.get_coverage_id( ) is None or self.session.get_coverage_id() == "": raise RecipeValidationException("No valid coverage id provided") import recipes.virtual_coverage.recipe as super_coverage if self.session.get_recipe_name() == super_coverage.Recipe.RECIPE_NAME: # NOTE: virtual_coverage recipe does not require any input files return if not FileUtil.check_dir_writable(ConfigManager.tmp_directory): raise RecipeValidationException( "Cannot write to tmp directory '{}'".format( ConfigManager.tmp_directory)) checked_files = [] for file in self.session.get_files(): if FileUtil.validate_file_path(file.get_filepath()): checked_files.append(file) if not ignore_no_files: # If no input file is available, exit wcst_import. FileUtil.validate_input_file_paths(checked_files) self.session.files = checked_files if 'wms_import' not in self.options: self.options['wms_import'] = False else: self.options['wms_import'] = bool(self.options['wms_import']) if 'tiling' not in self.options: self.options['tiling'] = None if 'scale_levels' not in self.options: self.options['scale_levels'] = None if 'scale_factors' not in self.options: self.options['scale_factors'] = None if self.options['scale_levels'] is not None \ and self.options['scale_factors'] is not None: raise RecipeValidationException( "Only one of 'scale_levels' or 'scale_factors' " "setting can exist in the ingredients file.") if self.options['scale_factors'] is not None: # as scale_factors and scale_levels are only valid when initializing a new coverage cov = CoverageUtil(self.session.get_coverage_id()) if not cov.exists(): for obj in self.options['scale_factors']: if 'coverage_id' not in obj or 'factors' not in obj: raise RecipeValidationException( "All elements of 'scale_factors' list must contain " "'coverage_id' and 'factors' properties") coverage_id = obj['coverage_id'] cov = CoverageUtil(coverage_id) if cov.exists(): raise RecipeValidationException( "Downscaled level coverage '" + coverage_id + "' already exists, " "please use a different 'coverage_id' in 'scale_factors' list" ) self.validate_pyramid_members() self.validate_pyramid_bases() if "import_order" in self.options: if self.options['import_order'] != AbstractToCoverageConverter.IMPORT_ORDER_ASCENDING \ and self.options['import_order'] != AbstractToCoverageConverter.IMPORT_ORDER_DESCENDING: error_message = "'import_order' option must be '{}' or '{}', given '{}'.".\ format(AbstractToCoverageConverter.IMPORT_ORDER_ASCENDING, AbstractToCoverageConverter.IMPORT_ORDER_DESCENDING, self.options['import_order']) raise RecipeValidationException(error_message) else: self.options['import_order'] = None