Loading Dockerfile +1 −5 Original line number Diff line number Diff line FROM alpine:3.8 FROM python:3.7-alpine LABEL maintainer="searx <https://github.com/asciimoo/searx>" LABEL description="A privacy-respecting, hackable metasearch engine." Loading @@ -12,9 +12,6 @@ COPY requirements.txt ./requirements.txt RUN apk -U add \ build-base \ python \ python-dev \ py-pip \ libxml2 \ libxml2-dev \ libxslt \ Loading @@ -27,7 +24,6 @@ RUN apk -U add \ && pip install --no-cache -r requirements.txt \ && apk del \ build-base \ python-dev \ libffi-dev \ openssl-dev \ libxslt-dev \ Loading Dockerfile.env +1 −1 Original line number Diff line number Diff line Loading @@ -5,4 +5,4 @@ RUN dnf install -y\ python2-pip\ npm\ && dnf groupinstall -y "Development Tools" \ && pip install pytest ipdb ipython \ && pip3 install pytest ipdb ipython manage.sh +8 −8 Original line number Diff line number Diff line Loading @@ -16,14 +16,14 @@ ACTION="$1" # update_packages() { pip install --upgrade pip pip install --upgrade setuptools pip install -r "$BASE_DIR/requirements.txt" pip3 install --upgrade pip pip3 install --upgrade setuptools pip3 install -r "$BASE_DIR/requirements.txt" } update_dev_packages() { update_packages pip install -r "$BASE_DIR/requirements-dev.txt" pip3 install -r "$BASE_DIR/requirements-dev.txt" } install_geckodriver() { Loading @@ -36,7 +36,7 @@ install_geckodriver() { return fi GECKODRIVER_VERSION="v0.19.1" PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`" PLATFORM="`python3 -c "import platform; print(platform.system().lower(), platform.architecture()[0])"`" case "$PLATFORM" in "linux 32bit" | "linux2 32bit") ARCH="linux32";; "linux 64bit" | "linux2 64bit") ARCH="linux64";; Loading Loading @@ -80,19 +80,19 @@ pep8_check() { unit_tests() { echo '[!] Running unit tests' python -m nose2 -s "$BASE_DIR/tests/unit" python3 -m nose2 -s "$BASE_DIR/tests/unit" } py_test_coverage() { echo '[!] Running python test coverage' PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ PYTHONPATH="`pwd`" python3 -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ && coverage report \ && coverage html } robot_tests() { echo '[!] Running robot tests' PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot PYTHONPATH="`pwd`" python3 "$SEARX_DIR/testing.py" robot } tests() { Loading searx/answerers/__init__.py +3 −7 Original line number Diff line number Diff line from os import listdir from os.path import realpath, dirname, join, isdir from sys import version_info from searx.utils import load_module from collections import defaultdict if version_info[0] == 3: unicode = str answerers_dir = dirname(realpath(__file__)) Loading Loading @@ -34,12 +30,12 @@ def get_answerers_by_keywords(answerers): def ask(query): results = [] query_parts = list(filter(None, query.query.split())) query_parts = list([_f for _f in query.query.split() if _f]) if query_parts[0].decode('utf-8') not in answerers_by_keywords: if query_parts[0] not in answerers_by_keywords: return results for answerer in answerers_by_keywords[query_parts[0].decode('utf-8')]: for answerer in answerers_by_keywords[query_parts[0]]: result = answerer(query) if result: results.append(result) Loading searx/answerers/random/answerer.py +13 −17 Original line number Diff line number Diff line Loading @@ -11,10 +11,6 @@ keywords = ('random',) random_int_max = 2**31 if sys.version_info[0] == 2: random_string_letters = string.lowercase + string.digits + string.uppercase else: unicode = str random_string_letters = string.ascii_lowercase + string.digits + string.ascii_uppercase Loading @@ -24,32 +20,32 @@ def random_characters(): def random_string(): return u''.join(random_characters()) return ''.join(random_characters()) def random_float(): return unicode(random.random()) return str(random.random()) def random_int(): return unicode(random.randint(-random_int_max, random_int_max)) return str(random.randint(-random_int_max, random_int_max)) def random_sha256(): m = hashlib.sha256() m.update(b''.join(random_characters())) return unicode(m.hexdigest()) m.update(''.join(random_characters()).encode()) return m.hexdigest() def random_uuid(): return unicode(uuid.uuid4()) return str(uuid.uuid4()) random_types = {b'string': random_string, b'int': random_int, b'float': random_float, b'sha256': random_sha256, b'uuid': random_uuid} random_types = {'string': random_string, 'int': random_int, 'float': random_float, 'sha256': random_sha256, 'uuid': random_uuid} # required answerer function Loading @@ -70,4 +66,4 @@ def answer(query): def self_info(): return {'name': gettext('Random value generator'), 'description': gettext('Generate different random values'), 'examples': [u'random {}'.format(x) for x in random_types]} 'examples': ['random {}'.format(x) for x in random_types]} Loading
Dockerfile +1 −5 Original line number Diff line number Diff line FROM alpine:3.8 FROM python:3.7-alpine LABEL maintainer="searx <https://github.com/asciimoo/searx>" LABEL description="A privacy-respecting, hackable metasearch engine." Loading @@ -12,9 +12,6 @@ COPY requirements.txt ./requirements.txt RUN apk -U add \ build-base \ python \ python-dev \ py-pip \ libxml2 \ libxml2-dev \ libxslt \ Loading @@ -27,7 +24,6 @@ RUN apk -U add \ && pip install --no-cache -r requirements.txt \ && apk del \ build-base \ python-dev \ libffi-dev \ openssl-dev \ libxslt-dev \ Loading
Dockerfile.env +1 −1 Original line number Diff line number Diff line Loading @@ -5,4 +5,4 @@ RUN dnf install -y\ python2-pip\ npm\ && dnf groupinstall -y "Development Tools" \ && pip install pytest ipdb ipython \ && pip3 install pytest ipdb ipython
manage.sh +8 −8 Original line number Diff line number Diff line Loading @@ -16,14 +16,14 @@ ACTION="$1" # update_packages() { pip install --upgrade pip pip install --upgrade setuptools pip install -r "$BASE_DIR/requirements.txt" pip3 install --upgrade pip pip3 install --upgrade setuptools pip3 install -r "$BASE_DIR/requirements.txt" } update_dev_packages() { update_packages pip install -r "$BASE_DIR/requirements-dev.txt" pip3 install -r "$BASE_DIR/requirements-dev.txt" } install_geckodriver() { Loading @@ -36,7 +36,7 @@ install_geckodriver() { return fi GECKODRIVER_VERSION="v0.19.1" PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`" PLATFORM="`python3 -c "import platform; print(platform.system().lower(), platform.architecture()[0])"`" case "$PLATFORM" in "linux 32bit" | "linux2 32bit") ARCH="linux32";; "linux 64bit" | "linux2 64bit") ARCH="linux64";; Loading Loading @@ -80,19 +80,19 @@ pep8_check() { unit_tests() { echo '[!] Running unit tests' python -m nose2 -s "$BASE_DIR/tests/unit" python3 -m nose2 -s "$BASE_DIR/tests/unit" } py_test_coverage() { echo '[!] Running python test coverage' PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ PYTHONPATH="`pwd`" python3 -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ && coverage report \ && coverage html } robot_tests() { echo '[!] Running robot tests' PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot PYTHONPATH="`pwd`" python3 "$SEARX_DIR/testing.py" robot } tests() { Loading
searx/answerers/__init__.py +3 −7 Original line number Diff line number Diff line from os import listdir from os.path import realpath, dirname, join, isdir from sys import version_info from searx.utils import load_module from collections import defaultdict if version_info[0] == 3: unicode = str answerers_dir = dirname(realpath(__file__)) Loading Loading @@ -34,12 +30,12 @@ def get_answerers_by_keywords(answerers): def ask(query): results = [] query_parts = list(filter(None, query.query.split())) query_parts = list([_f for _f in query.query.split() if _f]) if query_parts[0].decode('utf-8') not in answerers_by_keywords: if query_parts[0] not in answerers_by_keywords: return results for answerer in answerers_by_keywords[query_parts[0].decode('utf-8')]: for answerer in answerers_by_keywords[query_parts[0]]: result = answerer(query) if result: results.append(result) Loading
searx/answerers/random/answerer.py +13 −17 Original line number Diff line number Diff line Loading @@ -11,10 +11,6 @@ keywords = ('random',) random_int_max = 2**31 if sys.version_info[0] == 2: random_string_letters = string.lowercase + string.digits + string.uppercase else: unicode = str random_string_letters = string.ascii_lowercase + string.digits + string.ascii_uppercase Loading @@ -24,32 +20,32 @@ def random_characters(): def random_string(): return u''.join(random_characters()) return ''.join(random_characters()) def random_float(): return unicode(random.random()) return str(random.random()) def random_int(): return unicode(random.randint(-random_int_max, random_int_max)) return str(random.randint(-random_int_max, random_int_max)) def random_sha256(): m = hashlib.sha256() m.update(b''.join(random_characters())) return unicode(m.hexdigest()) m.update(''.join(random_characters()).encode()) return m.hexdigest() def random_uuid(): return unicode(uuid.uuid4()) return str(uuid.uuid4()) random_types = {b'string': random_string, b'int': random_int, b'float': random_float, b'sha256': random_sha256, b'uuid': random_uuid} random_types = {'string': random_string, 'int': random_int, 'float': random_float, 'sha256': random_sha256, 'uuid': random_uuid} # required answerer function Loading @@ -70,4 +66,4 @@ def answer(query): def self_info(): return {'name': gettext('Random value generator'), 'description': gettext('Generate different random values'), 'examples': [u'random {}'.format(x) for x in random_types]} 'examples': ['random {}'.format(x) for x in random_types]}