|
@@ -18,7 +18,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
|
18
|
18
|
import certifi
|
19
|
19
|
import logging
|
20
|
20
|
from os import environ
|
21
|
|
-from os.path import realpath, dirname, join, abspath
|
|
21
|
+from os.path import realpath, dirname, join, abspath, isfile
|
22
|
22
|
from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
|
23
|
23
|
try:
|
24
|
24
|
from yaml import load
|
|
@@ -30,13 +30,24 @@ except:
|
30
|
30
|
searx_dir = abspath(dirname(__file__))
|
31
|
31
|
engine_dir = dirname(realpath(__file__))
|
32
|
32
|
|
33
|
|
-# if possible set path to settings using the
|
34
|
|
-# enviroment variable SEARX_SETTINGS_PATH
|
|
33
|
+
|
|
34
|
+def check_settings_yml(file_name):
|
|
35
|
+ if isfile(file_name):
|
|
36
|
+ return file_name
|
|
37
|
+ else:
|
|
38
|
+ return None
|
|
39
|
+
|
|
40
|
+# find location of settings.yml
|
35
|
41
|
if 'SEARX_SETTINGS_PATH' in environ:
|
36
|
|
- settings_path = environ['SEARX_SETTINGS_PATH']
|
37
|
|
-# otherwise using default path
|
|
42
|
+ # if possible set path to settings using the
|
|
43
|
+ # enviroment variable SEARX_SETTINGS_PATH
|
|
44
|
+ settings_path = check_settings_yml(environ['SEARX_SETTINGS_PATH'])
|
38
|
45
|
else:
|
39
|
|
- settings_path = join(searx_dir, 'settings.yml')
|
|
46
|
+ # if not, get it from searx code base or last solution from /etc/searx
|
|
47
|
+ settings_path = check_settings_yml(join(searx_dir, 'settings.yml')) or check_settings_yml('/etc/searx/settings.yml')
|
|
48
|
+
|
|
49
|
+if not settings_path:
|
|
50
|
+ raise Exception('settings.yml not found')
|
40
|
51
|
|
41
|
52
|
# load settings
|
42
|
53
|
with open(settings_path) as settings_yaml:
|
|
@@ -67,7 +78,7 @@ else:
|
67
|
78
|
logging.basicConfig(level=logging.WARNING)
|
68
|
79
|
|
69
|
80
|
logger = logging.getLogger('searx')
|
70
|
|
-
|
|
81
|
+logger.debug('read configuration from %s', settings_path)
|
71
|
82
|
# Workaround for openssl versions <1.0.2
|
72
|
83
|
# https://github.com/certifi/python-certifi/issues/26
|
73
|
84
|
if OPENSSL_VERSION_INFO[0:3] < (1, 0, 2):
|