mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +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 argparse
|
||||||
|
import gzip
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import secrets
|
import secrets
|
||||||
@ -119,7 +120,7 @@ def subcommand_get_safe_search(_):
|
|||||||
def read_settings():
|
def read_settings():
|
||||||
"""Load settings as dictionary from YAML config file."""
|
"""Load settings as dictionary from YAML config file."""
|
||||||
with open(SETTINGS_FILE, 'rb') as settings_file:
|
with open(SETTINGS_FILE, 'rb') as settings_file:
|
||||||
return yaml.load(settings_file)
|
return yaml.safe_load(settings_file)
|
||||||
|
|
||||||
|
|
||||||
def write_settings(settings):
|
def write_settings(settings):
|
||||||
@ -136,6 +137,14 @@ def _get_example_settings_file():
|
|||||||
return searx_doc_dir / 'settings.yml.gz'
|
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(_):
|
def subcommand_setup(_):
|
||||||
"""Post installation actions for Searx"""
|
"""Post installation actions for Searx"""
|
||||||
_copy_uwsgi_configuration()
|
_copy_uwsgi_configuration()
|
||||||
@ -154,6 +163,7 @@ def subcommand_setup(_):
|
|||||||
_set_title(settings)
|
_set_title(settings)
|
||||||
_set_timeout(settings)
|
_set_timeout(settings)
|
||||||
_set_safe_search(settings)
|
_set_safe_search(settings)
|
||||||
|
_update_search_engines(settings)
|
||||||
write_settings(settings)
|
write_settings(settings)
|
||||||
|
|
||||||
action_utils.service_restart('uwsgi')
|
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
|
from .manifest import (PUBLIC_ACCESS_SETTING_FILE, # noqa, pylint: disable=unused-import
|
||||||
backup, clients)
|
backup, clients)
|
||||||
|
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
managed_packages = ['searx', 'uwsgi', 'uwsgi-plugin-python3']
|
managed_packages = ['searx', 'uwsgi', 'uwsgi-plugin-python3']
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user