Przeglądaj źródła

Merge branch 'master' of https://github.com/asciimoo/searx

Conflicts:
	searx/tests/test_engines.py
a01200356 9 lat temu
rodzic
commit
4130b3dfd6
73 zmienionych plików z 162 dodań i 730 usunięć
  1. 1
    12
      .gitignore
  2. 7
    7
      .travis.yml
  3. 0
    66
      Makefile
  4. 2
    115
      README.rst
  5. 0
    17
      base.cfg
  6. 0
    210
      bootstrap.py
  7. 0
    30
      buildout.cfg
  8. 94
    0
      manage.sh
  9. 0
    15
      minimal.cfg
  10. 0
    34
      production.cfg
  11. 10
    0
      requirements-dev.txt
  12. 12
    12
      requirements.txt
  13. 2
    2
      searx/engines/google.py
  14. 17
    3
      searx/testing.py
  15. 0
    47
      searx/tests/test_engines.py
  16. 7
    28
      setup.py
  17. 0
    0
      tests/__init__.py
  18. 0
    0
      tests/robot/__init__.py
  19. 0
    0
      tests/robot/test_basic.robot
  20. 0
    0
      tests/test_robot.py
  21. 0
    0
      tests/unit/__init__.py
  22. 0
    0
      tests/unit/engines/__init__.py
  23. 0
    0
      tests/unit/engines/test_bing.py
  24. 0
    0
      tests/unit/engines/test_bing_images.py
  25. 0
    0
      tests/unit/engines/test_bing_news.py
  26. 0
    0
      tests/unit/engines/test_blekko_images.py
  27. 0
    0
      tests/unit/engines/test_btdigg.py
  28. 0
    0
      tests/unit/engines/test_currency_convert.py
  29. 0
    0
      tests/unit/engines/test_dailymotion.py
  30. 0
    0
      tests/unit/engines/test_deezer.py
  31. 0
    0
      tests/unit/engines/test_deviantart.py
  32. 0
    0
      tests/unit/engines/test_digg.py
  33. 0
    0
      tests/unit/engines/test_duckduckgo.py
  34. 0
    0
      tests/unit/engines/test_duckduckgo_definitions.py
  35. 0
    0
      tests/unit/engines/test_dummy.py
  36. 0
    0
      tests/unit/engines/test_faroo.py
  37. 0
    0
      tests/unit/engines/test_flickr.py
  38. 0
    0
      tests/unit/engines/test_flickr_noapi.py
  39. 0
    0
      tests/unit/engines/test_gigablast.py
  40. 0
    0
      tests/unit/engines/test_github.py
  41. 10
    10
      tests/unit/engines/test_google.py
  42. 0
    0
      tests/unit/engines/test_google_images.py
  43. 0
    0
      tests/unit/engines/test_google_news.py
  44. 0
    0
      tests/unit/engines/test_kickass.py
  45. 0
    0
      tests/unit/engines/test_mediawiki.py
  46. 0
    0
      tests/unit/engines/test_mixcloud.py
  47. 0
    0
      tests/unit/engines/test_openstreetmap.py
  48. 0
    0
      tests/unit/engines/test_photon.py
  49. 0
    0
      tests/unit/engines/test_piratebay.py
  50. 0
    0
      tests/unit/engines/test_qwant.py
  51. 0
    0
      tests/unit/engines/test_searchcode_code.py
  52. 0
    0
      tests/unit/engines/test_searchcode_doc.py
  53. 0
    0
      tests/unit/engines/test_soundcloud.py
  54. 0
    0
      tests/unit/engines/test_spotify.py
  55. 0
    0
      tests/unit/engines/test_stackoverflow.py
  56. 0
    0
      tests/unit/engines/test_startpage.py
  57. 0
    0
      tests/unit/engines/test_subtitleseeker.py
  58. 0
    0
      tests/unit/engines/test_swisscows.py
  59. 0
    0
      tests/unit/engines/test_twitter.py
  60. 0
    0
      tests/unit/engines/test_vimeo.py
  61. 0
    0
      tests/unit/engines/test_www1x.py
  62. 0
    0
      tests/unit/engines/test_www500px.py
  63. 0
    0
      tests/unit/engines/test_yacy.py
  64. 0
    0
      tests/unit/engines/test_yahoo.py
  65. 0
    0
      tests/unit/engines/test_yahoo_news.py
  66. 0
    0
      tests/unit/engines/test_youtube_api.py
  67. 0
    0
      tests/unit/engines/test_youtube_noapi.py
  68. 0
    0
      tests/unit/test_plugins.py
  69. 0
    0
      tests/unit/test_results.py
  70. 0
    0
      tests/unit/test_search.py
  71. 0
    0
      tests/unit/test_utils.py
  72. 0
    0
      tests/unit/test_webapp.py
  73. 0
    122
      versions.cfg

+ 1
- 12
.gitignore Wyświetl plik

@@ -5,24 +5,13 @@ env
5 5
 robot_log.html
6 6
 robot_output.xml
7 7
 robot_report.html
8
+test_basic/
8 9
 setup.cfg
9 10
 
10 11
 *.pyc
11 12
 */*.pyc
12 13
 *~
13 14
 
14
-bin/
15
-build/
16
-coverage/
17
-develop-eggs/
18
-dist/
19
-eggs/
20
-include/
21
-lib/
22
-local/
23
-parts/
24
-searx.egg-info/
25
-var/
26 15
 node_modules/
27 16
 
28 17
 .tx/

+ 7
- 7
.travis.yml Wyświetl plik

@@ -11,16 +11,16 @@ before_install:
11 11
   - "export DISPLAY=:99.0"
12 12
   - "sh -e /etc/init.d/xvfb start"
13 13
   - npm install -g less grunt-cli
14
-  - ( cd searx/static/themes/oscar;npm install )
14
+  - ( cd searx/static/themes/oscar;npm install; cd - )
15 15
 install:
16
-  - "make"
16
+  - ./manage.sh update_dev_packages
17 17
   - pip install coveralls
18 18
 script:
19
-  - "make flake8"
20
-  - "make robot"
21
-  - "make styles"
22
-  - "make grunt"
23
-  - make coverage
19
+  - ./manage.sh pep8_check
20
+  - ./manage.sh styles
21
+  - ./manage.sh grunt_build
22
+  - ./manage.sh py_test_coverage
23
+  - ./manage.sh robot_tests
24 24
 after_success:
25 25
   coveralls
26 26
 notifications:

+ 0
- 66
Makefile Wyświetl plik

@@ -1,66 +0,0 @@
1
-# convenience makefile to boostrap & run buildout
2
-# use `make options=-v` to run buildout with extra options
3
-
4
-version = 2.7
5
-python = bin/python
6
-options =
7
-
8
-all: .installed.cfg
9
-
10
-.installed.cfg: bin/buildout buildout.cfg setup.py
11
-	bin/buildout $(options)
12
-
13
-bin/buildout: $(python) buildout.cfg bootstrap.py
14
-	$(python) bootstrap.py
15
-	@touch $@
16
-
17
-$(python):
18
-	virtualenv -p python$(version) --no-site-packages .
19
-	@touch $@
20
-
21
-robot: .installed.cfg
22
-	@bin/robot
23
-
24
-flake8: .installed.cfg
25
-	@bin/flake8 setup.py
26
-	@bin/flake8 ./searx/
27
-
28
-tests: .installed.cfg flake8
29
-	@bin/test
30
-	@grunt test --gruntfile searx/static/themes/oscar/gruntfile.js
31
-
32
-coverage: .installed.cfg
33
-	@bin/coverage run bin/test
34
-	@bin/coverage report
35
-	@bin/coverage html
36
-
37
-production: bin/buildout production.cfg setup.py
38
-	bin/buildout -c production.cfg $(options)
39
-	@echo "* Please modify `readlink --canonicalize-missing ./searx/settings.py`"
40
-	@echo "* Hint 1: on production, disable debug mode and change secret_key"
41
-	@echo "* Hint 2: searx will be executed at server startup by crontab"
42
-	@echo "* Hint 3: to run immediatley, execute 'bin/supervisord'"
43
-
44
-minimal: bin/buildout minimal.cfg setup.py
45
-	bin/buildout -c minimal.cfg $(options)
46
-
47
-styles:
48
-	@lessc -x searx/static/themes/default/less/style.less > searx/static/themes/default/css/style.css
49
-	@lessc -x searx/static/themes/default/less/style-rtl.less > searx/static/themes/default/css/style-rtl.css
50
-	@lessc -x searx/static/themes/courgette/less/style.less > searx/static/themes/courgette/css/style.css
51
-	@lessc -x searx/static/themes/courgette/less/style-rtl.less > searx/static/themes/courgette/css/style-rtl.css
52
-	@lessc -x searx/static/less/bootstrap/bootstrap.less > searx/static/css/bootstrap.min.css
53
-	@lessc -x searx/static/themes/oscar/less/oscar/oscar.less > searx/static/themes/oscar/css/oscar.min.css
54
-	@lessc -x searx/static/themes/pix-art/less/style.less > searx/static/themes/pix-art/css/style.css
55
-
56
-grunt:
57
-	@grunt --gruntfile searx/static/themes/oscar/gruntfile.js
58
-
59
-locales:
60
-	@pybabel compile -d searx/translations
61
-
62
-clean:
63
-	@rm -rf .installed.cfg .mr.developer.cfg bin parts develop-eggs eggs \
64
-		searx.egg-info lib include .coverage coverage
65
-
66
-.PHONY: all tests robot flake8 coverage production minimal styles locales clean

+ 2
- 115
README.rst Wyświetl plik

@@ -7,31 +7,16 @@ engine <https://en.wikipedia.org/wiki/Metasearch_engine>`__.
7 7
 List of `running
8 8
 instances <https://github.com/asciimoo/searx/wiki/Searx-instances>`__.
9 9
 
10
-See the `wiki <https://github.com/asciimoo/searx/wiki>`__ for more information.
10
+See the `documentation <https://asciimoo.github.io/searx>`__ and the `wiki <https://github.com/asciimoo/searx/wiki>`__ for more information.
11 11
 
12 12
 |Flattr searx|
13 13
 
14
-Features
15
-~~~~~~~~
16
-
17
-- Tracking free
18
-- Supports multiple output formats
19
-
20
-  - json ``curl https://searx.me/?format=json&q=[query]``
21
-  - csv ``curl https://searx.me/?format=csv&q=[query]``
22
-  - opensearch/rss ``curl https://searx.me/?format=rss&q=[query]``
23
-- Opensearch support (you can set as default search engine)
24
-- Configurable search engines/categories
25
-- Different search languages
26
-- Duckduckgo like !bang functionality with engine shortcuts
27
-- Parallel queries - relatively fast
28
-
29 14
 Installation
30 15
 ~~~~~~~~~~~~
31 16
 
32 17
 -  clone source:
33 18
    ``git clone git@github.com:asciimoo/searx.git && cd searx``
34
--  install dependencies: ``pip install -r requirements.txt``
19
+-  install dependencies: ``./manage.sh update_packages``
35 20
 -  edit your
36 21
    `settings.yml <https://github.com/asciimoo/searx/blob/master/settings.yml>`__
37 22
    (set your ``secret_key``!)
@@ -40,104 +25,6 @@ Installation
40 25
 For all the details, follow this `step by step
41 26
 installation <https://github.com/asciimoo/searx/wiki/Installation>`__
42 27
 
43
-Alternative (Recommended) Installation
44
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45
-
46
--  clone source:
47
-   ``git clone git@github.com:asciimoo/searx.git && cd searx``
48
--  build in current folder: ``make minimal``
49
--  run ``bin/searx-run`` to start the application
50
-
51
-Development
52
-~~~~~~~~~~~
53
-
54
-Just run ``make``. Versions of dependencies are pinned down inside
55
-``versions.cfg`` to produce most stable build. Also remember, NO make
56
-command should be run as root, not even ``make production``
57
-
58
-Deployment
59
-~~~~~~~~~~
60
-
61
--  clone source:
62
-   ``git clone git@github.com:asciimoo/searx.git && cd searx``
63
--  build in current folder: ``make production``
64
--  run ``bin/supervisord`` to start the application
65
-
66
-Upgrading
67
-~~~~~~~~~
68
-
69
--  inside previously cloned searx directory run: ``git stash`` to
70
-   temporarily save any changes you have made
71
--  pull source: ``git pull origin master``
72
--  re-build in current folder: ``make production``
73
--  run ``bin/supervisorctl stop searx`` to stop searx, if it does not,
74
-   then run ``fuser -k 8888/tcp``
75
--  run ``bin/supervisorctl reload`` to re-read supervisor config and
76
-   start searx
77
-
78
-Command make
79
-~~~~~~~~~~~~
80
-
81
-``make``
82
-''''''''
83
-
84
-Builds development environment with testing support.
85
-
86
-``make tests``
87
-''''''''''''''
88
-
89
-Runs tests. You can write tests
90
-`here <https://github.com/asciimoo/searx/tree/master/searx/tests>`__ and
91
-remember 'untested code is broken code'.
92
-
93
-``make robot``
94
-''''''''''''''
95
-
96
-Runs robot (Selenium) tests, you must have ``firefox`` installed because
97
-this functional tests actually run the browser and perform operations on
98
-it. Also searx is executed with
99
-`settings\_robot <https://github.com/asciimoo/searx/blob/master/searx/settings_robot.yml>`__.
100
-
101
-``make flake8``
102
-'''''''''''''''
103
-
104
-'pep8 is a tool to check your Python code against some of the style
105
-conventions in `PEP 8 <http://www.python.org/dev/peps/pep-0008/>`__.'
106
-
107
-``make coverage``
108
-'''''''''''''''''
109
-
110
-Checks coverage of tests, after running this, execute this:
111
-``firefox ./coverage/index.html``
112
-
113
-``make production``
114
-'''''''''''''''''''
115
-
116
-Used to make co-called production environment - without tests (you
117
-should ran tests before deploying searx on the server). This installs
118
-supervisord, so if searx crashes, it will try to pick itself up again.
119
-And crontab entry is added to start supervisord at server boot.
120
-
121
-``make minimal``
122
-''''''''''''''''
123
-
124
-Minimal build - without test frameworks, the quickest build option.
125
-
126
-``make clean``
127
-''''''''''''''
128
-
129
-Deletes several folders and files (see ``Makefile`` for more), so that
130
-next time you run any other ``make`` command it will rebuild everithing.
131
-
132
-TODO
133
-~~~~
134
-
135
-- Moar engines
136
-- Better ui
137
-- Browser integration
138
-- Documentation
139
-- Tests
140
-
141 28
 Bugs
142 29
 ~~~~
143 30
 

+ 0
- 17
base.cfg Wyświetl plik

@@ -1,17 +0,0 @@
1
-[buildout]
2
-extends = versions.cfg
3
-unzip = true
4
-newest = false
5
-prefer-final = true
6
-develop = .
7
-
8
-eggs =
9
-    searx
10
-
11
-parts =
12
-    omelette
13
-
14
-
15
-[omelette]
16
-recipe = collective.recipe.omelette
17
-eggs = ${buildout:eggs}

+ 0
- 210
bootstrap.py Wyświetl plik

@@ -1,210 +0,0 @@
1
-##############################################################################
2
-#
3
-# Copyright (c) 2006 Zope Foundation and Contributors.
4
-# All Rights Reserved.
5
-#
6
-# This software is subject to the provisions of the Zope Public License,
7
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
-# FOR A PARTICULAR PURPOSE.
12
-#
13
-##############################################################################
14
-"""Bootstrap a buildout-based project
15
-
16
-Simply run this script in a directory containing a buildout.cfg.
17
-The script accepts buildout command-line options, so you can
18
-use the -c option to specify an alternate configuration file.
19
-"""
20
-
21
-import os
22
-import shutil
23
-import sys
24
-import tempfile
25
-
26
-from optparse import OptionParser
27
-
28
-__version__ = '2015-07-01'
29
-# See zc.buildout's changelog if this version is up to date.
30
-
31
-tmpeggs = tempfile.mkdtemp(prefix='bootstrap-')
32
-
33
-usage = '''\
34
-[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
35
-
36
-Bootstraps a buildout-based project.
37
-
38
-Simply run this script in a directory containing a buildout.cfg, using the
39
-Python that you want bin/buildout to use.
40
-
41
-Note that by using --find-links to point to local resources, you can keep
42
-this script from going over the network.
43
-'''
44
-
45
-parser = OptionParser(usage=usage)
46
-parser.add_option("--version",
47
-                  action="store_true", default=False,
48
-                  help=("Return bootstrap.py version."))
49
-parser.add_option("-t", "--accept-buildout-test-releases",
50
-                  dest='accept_buildout_test_releases',
51
-                  action="store_true", default=False,
52
-                  help=("Normally, if you do not specify a --version, the "
53
-                        "bootstrap script and buildout gets the newest "
54
-                        "*final* versions of zc.buildout and its recipes and "
55
-                        "extensions for you.  If you use this flag, "
56
-                        "bootstrap and buildout will get the newest releases "
57
-                        "even if they are alphas or betas."))
58
-parser.add_option("-c", "--config-file",
59
-                  help=("Specify the path to the buildout configuration "
60
-                        "file to be used."))
61
-parser.add_option("-f", "--find-links",
62
-                  help=("Specify a URL to search for buildout releases"))
63
-parser.add_option("--allow-site-packages",
64
-                  action="store_true", default=False,
65
-                  help=("Let bootstrap.py use existing site packages"))
66
-parser.add_option("--buildout-version",
67
-                  help="Use a specific zc.buildout version")
68
-parser.add_option("--setuptools-version",
69
-                  help="Use a specific setuptools version")
70
-parser.add_option("--setuptools-to-dir",
71
-                  help=("Allow for re-use of existing directory of "
72
-                        "setuptools versions"))
73
-
74
-options, args = parser.parse_args()
75
-if options.version:
76
-    print("bootstrap.py version %s" % __version__)
77
-    sys.exit(0)
78
-
79
-
80
-######################################################################
81
-# load/install setuptools
82
-
83
-try:
84
-    from urllib.request import urlopen
85
-except ImportError:
86
-    from urllib2 import urlopen
87
-
88
-ez = {}
89
-if os.path.exists('ez_setup.py'):
90
-    exec(open('ez_setup.py').read(), ez)
91
-else:
92
-    exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
93
-
94
-if not options.allow_site_packages:
95
-    # ez_setup imports site, which adds site packages
96
-    # this will remove them from the path to ensure that incompatible versions
97
-    # of setuptools are not in the path
98
-    import site
99
-    # inside a virtualenv, there is no 'getsitepackages'.
100
-    # We can't remove these reliably
101
-    if hasattr(site, 'getsitepackages'):
102
-        for sitepackage_path in site.getsitepackages():
103
-            # Strip all site-packages directories from sys.path that
104
-            # are not sys.prefix; this is because on Windows
105
-            # sys.prefix is a site-package directory.
106
-            if sitepackage_path != sys.prefix:
107
-                sys.path[:] = [x for x in sys.path
108
-                               if sitepackage_path not in x]
109
-
110
-setup_args = dict(to_dir=tmpeggs, download_delay=0)
111
-
112
-if options.setuptools_version is not None:
113
-    setup_args['version'] = options.setuptools_version
114
-if options.setuptools_to_dir is not None:
115
-    setup_args['to_dir'] = options.setuptools_to_dir
116
-
117
-ez['use_setuptools'](**setup_args)
118
-import setuptools
119
-import pkg_resources
120
-
121
-# This does not (always?) update the default working set.  We will
122
-# do it.
123
-for path in sys.path:
124
-    if path not in pkg_resources.working_set.entries:
125
-        pkg_resources.working_set.add_entry(path)
126
-
127
-######################################################################
128
-# Install buildout
129
-
130
-ws = pkg_resources.working_set
131
-
132
-setuptools_path = ws.find(
133
-    pkg_resources.Requirement.parse('setuptools')).location
134
-
135
-# Fix sys.path here as easy_install.pth added before PYTHONPATH
136
-cmd = [sys.executable, '-c',
137
-       'import sys; sys.path[0:0] = [%r]; ' % setuptools_path +
138
-       'from setuptools.command.easy_install import main; main()',
139
-       '-mZqNxd', tmpeggs]
140
-
141
-find_links = os.environ.get(
142
-    'bootstrap-testing-find-links',
143
-    options.find_links or
144
-    ('http://downloads.buildout.org/'
145
-     if options.accept_buildout_test_releases else None)
146
-    )
147
-if find_links:
148
-    cmd.extend(['-f', find_links])
149
-
150
-requirement = 'zc.buildout'
151
-version = options.buildout_version
152
-if version is None and not options.accept_buildout_test_releases:
153
-    # Figure out the most recent final version of zc.buildout.
154
-    import setuptools.package_index
155
-    _final_parts = '*final-', '*final'
156
-
157
-    def _final_version(parsed_version):
158
-        try:
159
-            return not parsed_version.is_prerelease
160
-        except AttributeError:
161
-            # Older setuptools
162
-            for part in parsed_version:
163
-                if (part[:1] == '*') and (part not in _final_parts):
164
-                    return False
165
-            return True
166
-
167
-    index = setuptools.package_index.PackageIndex(
168
-        search_path=[setuptools_path])
169
-    if find_links:
170
-        index.add_find_links((find_links,))
171
-    req = pkg_resources.Requirement.parse(requirement)
172
-    if index.obtain(req) is not None:
173
-        best = []
174
-        bestv = None
175
-        for dist in index[req.project_name]:
176
-            distv = dist.parsed_version
177
-            if _final_version(distv):
178
-                if bestv is None or distv > bestv:
179
-                    best = [dist]
180
-                    bestv = distv
181
-                elif distv == bestv:
182
-                    best.append(dist)
183
-        if best:
184
-            best.sort()
185
-            version = best[-1].version
186
-if version:
187
-    requirement = '=='.join((requirement, version))
188
-cmd.append(requirement)
189
-
190
-import subprocess
191
-if subprocess.call(cmd) != 0:
192
-    raise Exception(
193
-        "Failed to execute command:\n%s" % repr(cmd)[1:-1])
194
-
195
-######################################################################
196
-# Import and run buildout
197
-
198
-ws.add_entry(tmpeggs)
199
-ws.require(requirement)
200
-import zc.buildout.buildout
201
-
202
-if not [a for a in args if '=' not in a]:
203
-    args.append('bootstrap')
204
-
205
-# if -c was provided, we push it back into args for buildout' main function
206
-if options.config_file is not None:
207
-    args[0:0] = ['-c', options.config_file]
208
-
209
-zc.buildout.buildout.main(args)
210
-shutil.rmtree(tmpeggs)

+ 0
- 30
buildout.cfg Wyświetl plik

@@ -1,30 +0,0 @@
1
-[buildout]
2
-extends = base.cfg
3
-develop = .
4
-
5
-eggs =
6
-    searx [test]
7
-
8
-parts +=
9
-    pyscripts
10
-    robot
11
-    test
12
-
13
-
14
-[pyscripts]
15
-recipe = zc.recipe.egg:script
16
-eggs = ${buildout:eggs}
17
-interpreter = py
18
-dependent-scripts = true
19
-
20
-
21
-[robot]
22
-recipe = zc.recipe.testrunner
23
-eggs = ${buildout:eggs}
24
-defaults = ['--color', '--auto-progress', '--layer', 'SearxRobotLayer']
25
-
26
-
27
-[test]
28
-recipe = zc.recipe.testrunner
29
-eggs = ${buildout:eggs}
30
-defaults = ['--color', '--auto-progress', '--layer', 'SearxTestLayer', '--layer', '!SearxRobotLayer']

+ 94
- 0
manage.sh Wyświetl plik

@@ -0,0 +1,94 @@
1
+#!/bin/sh
2
+
3
+BASE_DIR=$(dirname `readlink -f $0`)
4
+PYTHONPATH=$BASE_DIR
5
+SEARX_DIR="$BASE_DIR/searx"
6
+ACTION=$1
7
+
8
+update_packages() {
9
+    pip install --upgrade -r "$BASE_DIR/requirements.txt"
10
+}
11
+
12
+update_dev_packages() {
13
+    update_packages
14
+    pip install --upgrade -r "$BASE_DIR/requirements-dev.txt"
15
+}
16
+
17
+pep8_check() {
18
+    echo '[!] Running pep8 check'
19
+    pep8 --max-line-length=120 "$SEARX_DIR" "$BASE_DIR/tests"
20
+}
21
+
22
+unit_tests() {
23
+    echo '[!] Running unit tests'
24
+    python -m nose2 -s "$BASE_DIR/tests/unit"
25
+}
26
+
27
+py_test_coverage() {
28
+    echo '[!] Running python test coverage'
29
+    PYTHONPATH=`pwd` python -m nose2 -C --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit"
30
+    coverage report
31
+    coverage html
32
+}
33
+
34
+robot_tests() {
35
+    echo '[!] Running robot tests'
36
+    PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot
37
+}
38
+
39
+tests() {
40
+    set -e
41
+    pep8_check
42
+    unit_tests
43
+    robot_tests
44
+    set +e
45
+}
46
+
47
+build_style() {
48
+    lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
49
+}
50
+
51
+styles() {
52
+    echo '[!] Building styles'
53
+	build_style themes/default/less/style.less themes/default/css/style.css
54
+	build_style themes/default/less/style-rtl.less themes/default/css/style-rtl.css
55
+	build_style themes/courgette/less/style.less themes/courgette/css/style.css
56
+	build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
57
+	build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
58
+	build_style themes/oscar/less/oscar/oscar.less themes/oscar/css/oscar.min.css
59
+	build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
60
+}
61
+
62
+grunt_build() {
63
+	grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
64
+}
65
+
66
+locales() {
67
+	pybabel compile -d "$SEARX_DIR/translations"
68
+}
69
+
70
+help() {
71
+    [ -z "$1" ] || echo "Error: $1\n"
72
+    echo "Searx manage.sh help
73
+
74
+Commands
75
+========
76
+    grunt_build          - Build js files
77
+    help                 - This text
78
+    locales              - Compile locales
79
+    pep8_check           - Pep8 validation
80
+    py_test_coverage     - Unit test coverage
81
+    robot_tests          - Run selenium tests
82
+    styles               - Build less files
83
+    tests                - Run all python tests (pep8, unit, robot)
84
+    unit_tests           - Run unit tests
85
+    update_dev_packages  - Check & update development and production dependency changes
86
+    update_packages      - Check & update dependency changes
87
+"
88
+}
89
+
90
+if type $ACTION 1>/dev/null; then
91
+    $ACTION
92
+else
93
+    help "action not found"
94
+fi

+ 0
- 15
minimal.cfg Wyświetl plik

@@ -1,15 +0,0 @@
1
-[buildout]
2
-extends = base.cfg
3
-develop = .
4
-
5
-eggs =
6
-    searx
7
-
8
-parts +=
9
-    pyscripts
10
-
11
-
12
-[pyscripts]
13
-recipe = zc.recipe.egg:script
14
-eggs = ${buildout:eggs}
15
-interpreter = py

+ 0
- 34
production.cfg Wyświetl plik

@@ -1,34 +0,0 @@
1
-[buildout]
2
-extends = base.cfg
3
-develop = .
4
-
5
-eggs =
6
-    searx
7
-
8
-parts +=
9
-    pyscripts
10
-    supervisor
11
-    crontab_reboot
12
-
13
-
14
-[pyscripts]
15
-recipe = zc.recipe.egg:script
16
-eggs = ${buildout:eggs}
17
-interpreter = py
18
-
19
-
20
-[supervisor]
21
-recipe = collective.recipe.supervisor
22
-http-socket = unix
23
-user = searxer
24
-password = ohpleasedochangeme
25
-file = /tmp/supervisor.sock
26
-chmod = 0700
27
-programs =
28
-    50 searx    ${buildout:bin-directory}/searx-run
29
-
30
-
31
-[crontab_reboot]
32
-recipe = z3c.recipe.usercrontab
33
-times = @reboot
34
-command = ${buildout:bin-directory}/supervisord

+ 10
- 0
requirements-dev.txt Wyświetl plik

@@ -0,0 +1,10 @@
1
+babel==2.2.0
2
+flake8==2.5.1
3
+mock==1.0.1
4
+nose2[coverage-plugin]
5
+plone.testing==4.0.15
6
+robotframework-selenium2library==1.7.4
7
+robotsuite==1.7.0
8
+transifex-client==0.11
9
+unittest2==1.1.0
10
+zope.testrunner==4.4.10

+ 12
- 12
requirements.txt Wyświetl plik

@@ -1,12 +1,12 @@
1
-flask
2
-flask-babel
3
-requests
4
-lxml
5
-pyyaml
6
-pygments
7
-python-dateutil
8
-ndg-httpsclient
9
-pyopenssl
10
-pyasn1
11
-pyasn1-modules
12
-certifi
1
+certifi==2015.11.20.1
2
+flask==0.10.1
3
+flask-babel==0.9
4
+lxml==3.5.0
5
+ndg-httpsclient==0.4.0
6
+pyasn1==0.1.9
7
+pyasn1-modules==0.0.8
8
+pygments==2.0.2
9
+pyopenssl==0.15.1
10
+python-dateutil==2.4.2
11
+pyyaml==3.11
12
+requests==2.9.1

+ 2
- 2
searx/engines/google.py Wyświetl plik

@@ -90,7 +90,7 @@ url_map = 'https://www.openstreetmap.org/'\
90 90
 search_path = '/search'
91 91
 search_url = ('https://{hostname}' +
92 92
               search_path +
93
-              '?{query}&start={offset}&gbv=1&gws_rd=cr')
93
+              '?{query}&start={offset}&gbv=1&gws_rd=ssl')
94 94
 
95 95
 # other URLs
96 96
 map_hostname_start = 'maps.google.'
@@ -99,7 +99,7 @@ redirect_path = '/url'
99 99
 images_path = '/images'
100 100
 
101 101
 # specific xpath variables
102
-results_xpath = '//li[@class="g"]'
102
+results_xpath = '//div[@class="g"]'
103 103
 url_xpath = './/h3/a/@href'
104 104
 title_xpath = './/h3'
105 105
 content_xpath = './/span[@class="st"]'

+ 17
- 3
searx/testing.py Wyświetl plik

@@ -3,6 +3,7 @@
3 3
 
4 4
 from plone.testing import Layer
5 5
 from unittest2 import TestCase
6
+from os.path import dirname, join, abspath
6 7
 
7 8
 
8 9
 import os
@@ -42,11 +43,11 @@ class SearxRobotLayer(Layer):
42 43
             os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
43 44
             'webapp.py'
44 45
         )
45
-        exe = os.path.abspath(os.path.dirname(__file__) + '/../bin/py')
46
+        exe = 'python'
46 47
 
47 48
         # set robot settings path
48
-        os.environ['SEARX_SETTINGS_PATH'] = os.path.abspath(
49
-            os.path.dirname(__file__) + '/settings_robot.yml')
49
+        os.environ['SEARX_SETTINGS_PATH'] = abspath(
50
+            dirname(__file__) + '/settings_robot.yml')
50 51
 
51 52
         # run the server
52 53
         self.server = subprocess.Popen(
@@ -68,3 +69,16 @@ class SearxTestCase(TestCase):
68 69
     """Base test case for non-robot tests."""
69 70
 
70 71
     layer = SearxTestLayer
72
+
73
+
74
+if __name__ == '__main__':
75
+    from tests.test_robot import test_suite
76
+    import sys
77
+    from zope.testrunner.runner import Runner
78
+
79
+    base_dir = abspath(join(dirname(__file__), '../tests'))
80
+    if sys.argv[1] == 'robot':
81
+        Runner(['--color',
82
+                '--auto-progress',
83
+                '--path', base_dir],
84
+               found_suites=[test_suite()]).run()

+ 0
- 47
searx/tests/test_engines.py Wyświetl plik

@@ -1,47 +0,0 @@
1
-from searx.tests.engines.test_bing import *  # noqa
2
-from searx.tests.engines.test_bing_images import *  # noqa
3
-from searx.tests.engines.test_bing_news import *  # noqa
4
-from searx.tests.engines.test_blekko_images import *  # noqa
5
-from searx.tests.engines.test_btdigg import *  # noqa
6
-from searx.tests.engines.test_currency_convert import *  # noqa
7
-from searx.tests.engines.test_dailymotion import *  # noqa
8
-from searx.tests.engines.test_deezer import *  # noqa
9
-from searx.tests.engines.test_deviantart import *  # noqa
10
-from searx.tests.engines.test_digg import *  # noqa
11
-from searx.tests.engines.test_duckduckgo import *  # noqa
12
-from searx.tests.engines.test_duckduckgo_definitions import *  # noqa
13
-from searx.tests.engines.test_dummy import *  # noqa
14
-from searx.tests.engines.test_faroo import *  # noqa
15
-from searx.tests.engines.test_flickr import *  # noqa
16
-from searx.tests.engines.test_flickr_noapi import *  # noqa
17
-from searx.tests.engines.test_gigablast import *  # noqa
18
-from searx.tests.engines.test_github import *  # noqa
19
-from searx.tests.engines.test_google import *  # noqa
20
-from searx.tests.engines.test_google_images import *  # noqa
21
-from searx.tests.engines.test_google_news import *  # noqa
22
-from searx.tests.engines.test_kickass import *  # noqa
23
-from searx.tests.engines.test_mediawiki import *  # noqa
24
-from searx.tests.engines.test_mixcloud import *  # noqa
25
-from searx.tests.engines.test_openstreetmap import *  # noqa
26
-from searx.tests.engines.test_photon import *  # noqa
27
-from searx.tests.engines.test_piratebay import *  # noqa
28
-from searx.tests.engines.test_qwant import *  # noqa
29
-from searx.tests.engines.test_searchcode_code import *  # noqa
30
-from searx.tests.engines.test_searchcode_doc import *  # noqa
31
-from searx.tests.engines.test_soundcloud import *  # noqa
32
-from searx.tests.engines.test_spotify import *  # noqa
33
-from searx.tests.engines.test_stackoverflow import *  # noqa
34
-from searx.tests.engines.test_startpage import *  # noqa
35
-from searx.tests.engines.test_subtitleseeker import *  # noqa
36
-from searx.tests.engines.test_swisscows import *  # noqa
37
-from searx.tests.engines.test_twitter import *  # noqa
38
-from searx.tests.engines.test_vimeo import *  # noqa
39
-from searx.tests.engines.test_wolframalpha_api import *  # noqa
40
-from searx.tests.engines.test_wolframalpha_noapi import *  # noqa
41
-from searx.tests.engines.test_www1x import *  # noqa
42
-from searx.tests.engines.test_www500px import *  # noqa
43
-from searx.tests.engines.test_yacy import *  # noqa
44
-from searx.tests.engines.test_yahoo import *  # noqa
45
-from searx.tests.engines.test_youtube_api import *  # noqa
46
-from searx.tests.engines.test_youtube_noapi import *  # noqa
47
-from searx.tests.engines.test_yahoo_news import *  # noqa

+ 7
- 28
setup.py Wyświetl plik

@@ -17,6 +17,8 @@ def read(*rnames):
17 17
 
18 18
 
19 19
 long_description = read('README.rst')
20
+requirements = map(str.strip, open('requirements.txt').readlines())
21
+dev_requirements = map(str.strip, open('requirements-dev.txt').readlines())
20 22
 
21 23
 setup(
22 24
     name='searx',
@@ -38,35 +40,9 @@ setup(
38 40
     license='GNU Affero General Public License',
39 41
     packages=find_packages('.'),
40 42
     zip_safe=False,
41
-    install_requires=[
42
-        'flask',
43
-        'flask-babel',
44
-        'requests',
45
-        'lxml',
46
-        'pyyaml',
47
-        'pygments',
48
-        'setuptools',
49
-        'python-dateutil',
50
-        'pyopenssl',
51
-        'ndg-httpsclient',
52
-        'pyasn1',
53
-        'pyasn1-modules',
54
-        'certifi'
55
-    ],
43
+    install_requires=requirements,
56 44
     extras_require={
57
-        'test': [
58
-            'coverage',
59
-            'flake8',
60
-            'mock',
61
-            'plone.testing',
62
-            'robotframework',
63
-            'robotframework-debuglibrary',
64
-            'robotframework-httplibrary',
65
-            'robotframework-selenium2library',
66
-            'robotsuite',
67
-            'unittest2',
68
-            'zope.testrunner',
69
-        ]
45
+        'test': dev_requirements
70 46
     },
71 47
     entry_points={
72 48
         'console_scripts': [
@@ -86,6 +62,9 @@ setup(
86 62
             'static/*/*/*/*/*.*',
87 63
             'templates/*/*.*',
88 64
             'templates/*/*/*.*',
65
+            'tests/*',
66
+            'tests/*/*',
67
+            'tests/*/*/*',
89 68
             'translations/*/*/*'
90 69
         ],
91 70
     },

searx/tests/robot/__init__.py → tests/__init__.py Wyświetl plik


searx/tests/engines/__init__.py → tests/robot/__init__.py Wyświetl plik


searx/tests/robot/test_basic.robot → tests/robot/test_basic.robot Wyświetl plik


searx/tests/test_robot.py → tests/test_robot.py Wyświetl plik


searx/tests/__init__.py → tests/unit/__init__.py Wyświetl plik


+ 0
- 0
tests/unit/engines/__init__.py Wyświetl plik


searx/tests/engines/test_bing.py → tests/unit/engines/test_bing.py Wyświetl plik


searx/tests/engines/test_bing_images.py → tests/unit/engines/test_bing_images.py Wyświetl plik


searx/tests/engines/test_bing_news.py → tests/unit/engines/test_bing_news.py Wyświetl plik


searx/tests/engines/test_blekko_images.py → tests/unit/engines/test_blekko_images.py Wyświetl plik


searx/tests/engines/test_btdigg.py → tests/unit/engines/test_btdigg.py Wyświetl plik


searx/tests/engines/test_currency_convert.py → tests/unit/engines/test_currency_convert.py Wyświetl plik


searx/tests/engines/test_dailymotion.py → tests/unit/engines/test_dailymotion.py Wyświetl plik


searx/tests/engines/test_deezer.py → tests/unit/engines/test_deezer.py Wyświetl plik


searx/tests/engines/test_deviantart.py → tests/unit/engines/test_deviantart.py Wyświetl plik


searx/tests/engines/test_digg.py → tests/unit/engines/test_digg.py Wyświetl plik


searx/tests/engines/test_duckduckgo.py → tests/unit/engines/test_duckduckgo.py Wyświetl plik


searx/tests/engines/test_duckduckgo_definitions.py → tests/unit/engines/test_duckduckgo_definitions.py Wyświetl plik


searx/tests/engines/test_dummy.py → tests/unit/engines/test_dummy.py Wyświetl plik


searx/tests/engines/test_faroo.py → tests/unit/engines/test_faroo.py Wyświetl plik


searx/tests/engines/test_flickr.py → tests/unit/engines/test_flickr.py Wyświetl plik


searx/tests/engines/test_flickr_noapi.py → tests/unit/engines/test_flickr_noapi.py Wyświetl plik


searx/tests/engines/test_gigablast.py → tests/unit/engines/test_gigablast.py Wyświetl plik


searx/tests/engines/test_github.py → tests/unit/engines/test_github.py Wyświetl plik


searx/tests/engines/test_google.py → tests/unit/engines/test_google.py Wyświetl plik

@@ -40,7 +40,7 @@ class TestGoogleEngine(SearxTestCase):
40 40
         self.assertEqual(google.response(response), [])
41 41
 
42 42
         html = """
43
-        <li class="g">
43
+        <div class="g">
44 44
             <h3 class="r">
45 45
                 <a href="http://this.should.be.the.link/">
46 46
                     <b>This</b> is <b>the</b> title
@@ -94,35 +94,35 @@ class TestGoogleEngine(SearxTestCase):
94 94
                     </a>
95 95
                 </div>
96 96
             </div>
97
-        </li>
98
-        <li class="g">
97
+        </div>
98
+        <div class="g">
99 99
             <h3 class="r">
100 100
                 <a href="http://www.google.com/images?q=toto">
101 101
                     <b>This</b>
102 102
                 </a>
103 103
             </h3>
104
-        </li>
105
-        <li class="g">
104
+        </div>
105
+        <div class="g">
106 106
             <h3 class="r">
107 107
                 <a href="http://www.google.com/search?q=toto">
108 108
                     <b>This</b> is
109 109
                 </a>
110 110
             </h3>
111
-        </li>
112
-        <li class="g">
111
+        </div>
112
+        <div class="g">
113 113
             <h3 class="r">
114 114
                 <a href="€">
115 115
                     <b>This</b> is <b>the</b>
116 116
                 </a>
117 117
             </h3>
118
-        </li>
119
-        <li class="g">
118
+        </div>
119
+        <div class="g">
120 120
             <h3 class="r">
121 121
                 <a href="/url?q=url">
122 122
                     <b>This</b> is <b>the</b>
123 123
                 </a>
124 124
             </h3>
125
-        </li>
125
+        </div>
126 126
         <p class="_Bmc" style="margin:3px 8px">
127 127
             <a href="/search?num=20&amp;safe=off&amp;q=t&amp;revid=1754833769&amp;sa=X&amp;ei=-&amp;ved=">
128 128
                 suggestion <b>title</b>

searx/tests/engines/test_google_images.py → tests/unit/engines/test_google_images.py Wyświetl plik


searx/tests/engines/test_google_news.py → tests/unit/engines/test_google_news.py Wyświetl plik


searx/tests/engines/test_kickass.py → tests/unit/engines/test_kickass.py Wyświetl plik


searx/tests/engines/test_mediawiki.py → tests/unit/engines/test_mediawiki.py Wyświetl plik


searx/tests/engines/test_mixcloud.py → tests/unit/engines/test_mixcloud.py Wyświetl plik


searx/tests/engines/test_openstreetmap.py → tests/unit/engines/test_openstreetmap.py Wyświetl plik


searx/tests/engines/test_photon.py → tests/unit/engines/test_photon.py Wyświetl plik


searx/tests/engines/test_piratebay.py → tests/unit/engines/test_piratebay.py Wyświetl plik


searx/tests/engines/test_qwant.py → tests/unit/engines/test_qwant.py Wyświetl plik


searx/tests/engines/test_searchcode_code.py → tests/unit/engines/test_searchcode_code.py Wyświetl plik


searx/tests/engines/test_searchcode_doc.py → tests/unit/engines/test_searchcode_doc.py Wyświetl plik


searx/tests/engines/test_soundcloud.py → tests/unit/engines/test_soundcloud.py Wyświetl plik


searx/tests/engines/test_spotify.py → tests/unit/engines/test_spotify.py Wyświetl plik


searx/tests/engines/test_stackoverflow.py → tests/unit/engines/test_stackoverflow.py Wyświetl plik


searx/tests/engines/test_startpage.py → tests/unit/engines/test_startpage.py Wyświetl plik


searx/tests/engines/test_subtitleseeker.py → tests/unit/engines/test_subtitleseeker.py Wyświetl plik


searx/tests/engines/test_swisscows.py → tests/unit/engines/test_swisscows.py Wyświetl plik


searx/tests/engines/test_twitter.py → tests/unit/engines/test_twitter.py Wyświetl plik


searx/tests/engines/test_vimeo.py → tests/unit/engines/test_vimeo.py Wyświetl plik


searx/tests/engines/test_www1x.py → tests/unit/engines/test_www1x.py Wyświetl plik


searx/tests/engines/test_www500px.py → tests/unit/engines/test_www500px.py Wyświetl plik


searx/tests/engines/test_yacy.py → tests/unit/engines/test_yacy.py Wyświetl plik


searx/tests/engines/test_yahoo.py → tests/unit/engines/test_yahoo.py Wyświetl plik


searx/tests/engines/test_yahoo_news.py → tests/unit/engines/test_yahoo_news.py Wyświetl plik


searx/tests/engines/test_youtube_api.py → tests/unit/engines/test_youtube_api.py Wyświetl plik


searx/tests/engines/test_youtube_noapi.py → tests/unit/engines/test_youtube_noapi.py Wyświetl plik


searx/tests/test_plugins.py → tests/unit/test_plugins.py Wyświetl plik


searx/tests/test_results.py → tests/unit/test_results.py Wyświetl plik


searx/tests/test_search.py → tests/unit/test_search.py Wyświetl plik


searx/tests/test_utils.py → tests/unit/test_utils.py Wyświetl plik


searx/tests/test_webapp.py → tests/unit/test_webapp.py Wyświetl plik


+ 0
- 122
versions.cfg Wyświetl plik

@@ -1,122 +0,0 @@
1
-[versions]
2
-Babel = 1.3
3
-Flask = 0.10.1
4
-Flask-Babel = 0.9
5
-Jinja2 = 2.7.3
6
-MarkupSafe = 0.23
7
-Pygments = 2.0.2
8
-WebOb = 1.4.1
9
-WebTest = 2.0.18
10
-Werkzeug = 0.10.4
11
-collective.recipe.omelette = 0.16
12
-coverage = 3.7.1
13
-decorator = 3.4.2
14
-docutils = 0.12
15
-flake8 = 2.4.1
16
-itsdangerous = 0.24
17
-mccabe = 0.3.1
18
-mock = 1.0.1
19
-pep8 = 1.5.7
20
-plone.testing = 4.0.13
21
-pyflakes = 0.8.1
22
-pytz = 2015.4
23
-pyyaml = 3.11
24
-requests = 2.7.0
25
-robotframework-debuglibrary = 0.3
26
-robotframework-httplibrary = 0.4.2
27
-robotframework-selenium2library = 1.7.1
28
-robotsuite = 1.6.1
29
-selenium = 2.46.0
30
-speaklater = 1.3
31
-unittest2 = 1.0.1
32
-waitress = 0.8.9
33
-zc.recipe.testrunner = 2.0.0
34
-pyopenssl = 0.15.1
35
-ndg-httpsclient = 0.4.0
36
-pyasn1 = 0.1.8
37
-pyasn1-modules = 0.0.6
38
-certifi = 2015.11.20.1
39
-
40
-cffi = 1.1.2
41
-cryptography = 0.9.1
42
-
43
-# Required by:
44
-# robotsuite==1.6.1
45
-# searx==0.7.0
46
-lxml = 3.4.4
47
-
48
-# Required by:
49
-# searx==0.7.0
50
-python-dateutil = 2.4.2
51
-
52
-# Required by:
53
-# searx==0.7.0
54
-# zope.exceptions==4.0.7
55
-# zope.interface==4.1.2
56
-# zope.testrunner==4.4.9
57
-setuptools = 18.0.1
58
-
59
-# Required by:
60
-# WebTest==2.0.18
61
-beautifulsoup4 = 4.3.2
62
-
63
-# Required by:
64
-# cryptography==0.9.1
65
-enum34 = 1.0.4
66
-
67
-# Required by:
68
-# cryptography==0.9.1
69
-idna = 2.0
70
-
71
-# Required by:
72
-# cryptography==0.9.1
73
-ipaddress = 1.0.7
74
-
75
-# Required by:
76
-# robotframework-httplibrary==0.4.2
77
-jsonpatch = 1.11
78
-
79
-# Required by:
80
-# robotframework-httplibrary==0.4.2
81
-jsonpointer = 1.9
82
-
83
-# Required by:
84
-# traceback2==1.4.0
85
-linecache2 = 1.0.0
86
-
87
-# Required by:
88
-# cffi==1.1.2
89
-pycparser = 2.12
90
-
91
-# Required by:
92
-# robotframework-httplibrary==0.4.2
93
-robotframework = 2.8.7
94
-
95
-# Required by:
96
-# robotsuite==1.6.1
97
-# zope.testrunner==4.4.9
98
-six = 1.9.0
99
-
100
-# Required by:
101
-# unittest2==1.0.1
102
-traceback2 = 1.4.0
103
-
104
-# Required by:
105
-# collective.recipe.omelette==0.16
106
-zc.recipe.egg = 2.0.1
107
-
108
-# Required by:
109
-# zope.testrunner==4.4.9
110
-zope.exceptions = 4.0.7
111
-
112
-# Required by:
113
-# zope.testrunner==4.4.9
114
-zope.interface = 4.1.2
115
-
116
-# Required by:
117
-# plone.testing==4.0.13
118
-zope.testing = 4.2.0
119
-
120
-# Required by:
121
-# zc.recipe.testrunner==2.0.0
122
-zope.testrunner = 4.4.9