Skip to content
Open

2to3 #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions admin/config.py
Original file line number Diff line number Diff line change
@@ -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)
26 changes: 13 additions & 13 deletions admin/reference_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions admin/searx_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}
Expand All @@ -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

Expand Down Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions admin/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down