def validate_args(arguments, err_strings, init_logging): # configure logger to log to filesystem if init_logging: if arguments.target_base_dir: folder = c_path.normalize(arguments.target_base_dir) try: c_path.create_dir(folder) except Exception as e: raise RuntimeError('Unable to create directory for logging: ' + folder + '\n' + 'Error: ' + str(e)) if arguments.sign_id: logging_file_name = SECTOOLS_BUILDER_TOOL_NAME.replace( " ", "_") + "_" + arguments.sign_id else: logging_file_name = SECTOOLS_BUILDER_TOOL_NAME.replace( " ", "_") logger.enable_file_logging(logging_file_name, num_logs=1, log_dir=folder) else: raise RuntimeError(err_strings[0]) err = [] # validate that the required fields were provided if not arguments.target_base_dir: err.append(err_strings[0]) if not arguments.source: err.append(err_strings[1]) if not arguments.sign_id: err.append(err_strings[2]) if arguments.jtag_id and arguments.soc_hw_version: err.append(err_strings[3]) if hasattr(arguments, "config_type") and arguments.config_type is not None: logger.info("Sectools Builder config was provided using new api") config = c_path.normalize(arguments.config_type) if config not in CONFIGS: err.append(err_strings[8]) else: logger.info( "Sectools Builder config was provided using deprecated api") config = c_path.normalize(arguments.config) if config not in CONFIGS: logger.warning( "Sectools Builder received custom Secimage config file") sectools_builder_core.validate_file(config, err_strings[4], err) validate_bool(arguments.qti_sign, err_strings[5], err) validate_bool(arguments.relocatable, err_strings[6], err) if hasattr( arguments, "target_image_type_filter" ) and arguments.target_image_type_filter is not None and arguments.target_image_type_filter not in [ sectools_builder_core.INTEGRITY, sectools_builder_core.SIGN, sectools_builder_core.ENCRYPT, sectools_builder_core.SIGN_AND_ENCRYPT ]: err.append(err_strings[7]) return error_list_to_str(err)
def log_to_file(folder): """Configures the logger to log to filesystem :param str folder: Directory to generate the logs in. """ folder = c_path.normalize(folder) try: c_path.create_dir(folder) except Exception as e: raise RuntimeError('Unable to create directory for logging: ' + folder + '\n' ' ' + 'Error: ' + str(e)) logger.enable_file_logging(FUSEBLOWER_TOOL_NAME, num_logs=1, log_dir=folder)