mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
searx: Update search engines for 0.16.0
- Handle gzipped example settings files - Fix yaml.load deprecation warnings Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
cb7a9475bc
commit
5944e13cf0
@ -5,6 +5,7 @@ Configuration helper for searx.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import os
|
||||
import pathlib
|
||||
import secrets
|
||||
@ -119,7 +120,7 @@ def subcommand_get_safe_search(_):
|
||||
def read_settings():
|
||||
"""Load settings as dictionary from YAML config file."""
|
||||
with open(SETTINGS_FILE, 'rb') as settings_file:
|
||||
return yaml.load(settings_file)
|
||||
return yaml.safe_load(settings_file)
|
||||
|
||||
|
||||
def write_settings(settings):
|
||||
@ -136,6 +137,14 @@ def _get_example_settings_file():
|
||||
return searx_doc_dir / 'settings.yml.gz'
|
||||
|
||||
|
||||
def _update_search_engines(settings):
|
||||
"""Updates settings with the latest supported search engines."""
|
||||
example_settings_file = _get_example_settings_file()
|
||||
open_func = gzip.open if example_settings_file.suffix == '.gz' else open
|
||||
with open_func(example_settings_file, 'rb') as example_settings:
|
||||
settings['engines'] = yaml.safe_load(example_settings)['engines']
|
||||
|
||||
|
||||
def subcommand_setup(_):
|
||||
"""Post installation actions for Searx"""
|
||||
_copy_uwsgi_configuration()
|
||||
@ -154,6 +163,7 @@ def subcommand_setup(_):
|
||||
_set_title(settings)
|
||||
_set_timeout(settings)
|
||||
_set_safe_search(settings)
|
||||
_update_search_engines(settings)
|
||||
write_settings(settings)
|
||||
|
||||
action_utils.service_restart('uwsgi')
|
||||
|
||||
@ -17,7 +17,7 @@ from plinth.modules.users import register_group
|
||||
from .manifest import (PUBLIC_ACCESS_SETTING_FILE, # noqa, pylint: disable=unused-import
|
||||
backup, clients)
|
||||
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
managed_packages = ['searx', 'uwsgi', 'uwsgi-plugin-python3']
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user