diff --git a/lookyloo/helpers.py b/lookyloo/helpers.py index 06753e4..fb7a4c8 100644 --- a/lookyloo/helpers.py +++ b/lookyloo/helpers.py @@ -122,7 +122,7 @@ def load_configs(path_to_config_files: Optional[Union[str, Path]]=None): @lru_cache(64) -def get_config(config_type: str, entry: str) -> Any: +def get_config(config_type: str, entry: str, quiet: bool=False) -> Any: """Get an entry from the given config_type file. Automatic fallback to the sample file""" global configs if not configs: @@ -131,10 +131,13 @@ def get_config(config_type: str, entry: str) -> Any: if entry in configs[config_type]: return configs[config_type][entry] else: - logger.warning(f'Unable to find {entry} in config file.') + if not quiet: + logger.warning(f'Unable to find {entry} in config file.') else: - logger.warning(f'No {config_type} config file available.') - logger.warning(f'Falling back on sample config, please initialize the {config_type} config file.') + if not quiet: + logger.warning(f'No {config_type} config file available.') + if not quiet: + logger.warning(f'Falling back on sample config, please initialize the {config_type} config file.') with (get_homedir() / 'config' / f'{config_type}.json.sample').open() as _c: sample_config = json.load(_c) return sample_config[entry] diff --git a/tools/validate_config_files.py b/tools/validate_config_files.py index 4679414..acc2cd2 100755 --- a/tools/validate_config_files.py +++ b/tools/validate_config_files.py @@ -40,7 +40,7 @@ def validate_generic_config_file(): # Make sure the user config file doesn't have entries missing in the sample config for key in generic_config.keys(): if key not in generic_config_sample: - raise Exception(f'{key} is missing in the sample config file') + raise Exception(f'{key} is missing in the sample config file. You need to compare {user_config} with {user_config}.sample.') return True diff --git a/website/web/__init__.py b/website/web/__init__.py index 18f4678..2e8ceca 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -47,8 +47,8 @@ app.debug = False login_manager = flask_login.LoginManager() login_manager.init_app(app) try: - # Use legacy user mgmt - users = get_config('generic', 'cache_clean_user') + # Use legacy user mgmt, no need to print a warning, and it will fail on new install. + users = get_config('generic', 'cache_clean_user', quiet=True) except Exception: users = get_config('generic', 'users')