mirror of https://github.com/CIRCL/lookyloo
fix: Make get legacy user config quiet
parent
39dd2021dd
commit
d711fd3644
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue