diff --git a/admin/config.py b/admin/config.py index 8e07f29..8761cd8 100644 --- a/admin/config.py +++ b/admin/config.py @@ -1,5 +1,5 @@ import yaml -with open('admin/config.yml') as config_file: - configuration = yaml.load(config_file) +with open('/etc/searx-admin/config.yml') as config_file: + configuration = yaml.safe_load(config_file) diff --git a/admin/reference_settings.yml b/admin/reference_settings.yml index 9e09baf..202fffb 100644 --- a/admin/reference_settings.yml +++ b/admin/reference_settings.yml @@ -188,9 +188,9 @@ engines: # shortcut : fa # api_key : 'apikey' # required! - - name : 500px - engine : www500px - shortcut : px +# - name : 500px +# engine : www500px +# shortcut : px - name : 1x engine : www1x @@ -505,13 +505,13 @@ engines: shortcut : se categories : science - - name : spotify - engine : spotify - shortcut : stf +# - name : spotify +# engine : spotify +# shortcut : stf - - name : subtitleseeker - engine : subtitleseeker - shortcut : ss +# - name : subtitleseeker +# engine : subtitleseeker +# shortcut : ss # The language is an option. You can put any language written in english # Examples : English, French, German, Hungarian, Chinese... # language : English @@ -530,10 +530,10 @@ engines: timeout : 6.0 disabled : True - - name : swisscows - engine : swisscows - shortcut : sw - disabled : True +# - name : swisscows +# engine : swisscows +# shortcut : sw +# disabled : True - name : tokyotoshokan engine : tokyotoshokan diff --git a/admin/searx_manager.py b/admin/searx_manager.py index c845374..6a4b353 100644 --- a/admin/searx_manager.py +++ b/admin/searx_manager.py @@ -56,28 +56,28 @@ class Searx(object): safe_search_options = [('0', 'None'), ('1', 'Moderate'), ('2', 'Strict')] - autocomplete_options = zip(list(autocomplete.backends.keys()) + [''], - list(autocomplete.backends.keys()) + ['-']) + autocomplete_options = list(zip(list(autocomplete.backends.keys()) + [''], + list(autocomplete.backends.keys()) + ['-'])) def __init__(self, root, uwsgi_extra_args): self.root_folder = root self.uwsgi_extra_args = uwsgi_extra_args with open(REFERENCE_SETTINGS_PATH) as config_file: config = config_file.read() - self.settings = yaml.load(config) + self.settings = yaml.safe_load(config) self.engines = load_engines(self.settings['engines']) if isfile(EDITABLE_SETTINGS_PATH): with open(EDITABLE_SETTINGS_PATH) as config_file2: - self._merge_settings(yaml.load(config_file2.read())) + self._merge_settings(yaml.safe_load(config_file2.read())) else: with open(EDITABLE_SETTINGS_PATH, 'w') as outfile: outfile.write(config) def _merge_settings(self, new_settings): - for k, s in new_settings.items(): + for k, s in list(new_settings.items()): if k == 'engines': continue - for kk, c in s.items(): + for kk, c in list(s.items()): self.settings[k][kk] = c editable_engines = {e['name']: e for e in new_settings['engines']} @@ -93,7 +93,7 @@ def _save(self, new_settings): try: new_val = val_type(new_val) except: - print("Failed to parse settings attribute", section, '->', val_name) + print(("Failed to parse settings attribute", section, '->', val_name)) continue self.settings[new_settings['section']][key] = new_val @@ -176,7 +176,7 @@ def update(self): with open(REFERENCE_SETTINGS_PATH, 'w') as outfile: outfile.write(new_reference_settings.encode('utf-8')) except Exception as e: - print('Failed to fetch new references settings.yml', e) + print(('Failed to fetch new references settings.yml', e)) self.reload() diff --git a/admin/webapp.py b/admin/webapp.py index 5d28a76..d531164 100644 --- a/admin/webapp.py +++ b/admin/webapp.py @@ -85,7 +85,7 @@ def search(): def _setup_locales_to_display(): locales = [] - for key, val in instance.settings['locales'].items(): + for key, val in list(instance.settings['locales'].items()): locales.append((key, val)) locales.append(('', 'Default')) return locales @@ -126,14 +126,14 @@ def edit_engine(engine_name): continue attr_value = getattr(engine, attr) attr_type = type(attr_value) - if attr_type not in (str, int, float, bool, unicode): + if attr_type not in (str, int, float, bool, str): continue if request.method == 'POST': try: attr_value = attr_type(request.form[attr]) setattr(engine, attr, attr_value) except: - print("attr not found or type mismatched", attr, attr_type, request.form.get(attr)) + print(("attr not found or type mismatched", attr, attr_type, request.form.get(attr))) attrs.append((attr, attr_value, type_map[attr_type])) if request.method == 'POST': instance.save_settings({'section': 'engine', 'engine': engine})