on v0.12.0 help sign in
searx/manage.sh
128 lines 3.9 kB history raw
1#!/bin/sh
3BASE_DIR=$(dirname "`readlink -f "$0"`")
4PYTHONPATH=$BASE_DIR
5SEARX_DIR="$BASE_DIR/searx"
6ACTION=$1
8update_packages() {
9 pip install -r "$BASE_DIR/requirements.txt"
12update_dev_packages() {
13 update_packages
14 pip install -r "$BASE_DIR/requirements-dev.txt"
17check_geckodriver() {
18 echo '[!] Checking geckodriver'
19 set -e
20 geckodriver -V 2>1 > /dev/null || NOTFOUND=1
21 set +e
22 if [ -z $NOTFOUND ]; then
23 return
24 fi
25 GECKODRIVER_VERSION="v0.11.1"
26 PLATFORM=`python -c "import platform; print platform.system().lower(), platform.architecture()[0]"`
27 case $PLATFORM in
28 "linux 32bit" | "linux2 32bit") ARCH="linux32";;
29 "linux 64bit" | "linux2 64bit") ARCH="linux64";;
30 "windows 32 bit") ARCH="win32";;
31 "windows 64 bit") ARCH="win64";;
32 "mac 64bit") ARCH="macos";;
33 esac
34 GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
35 if [ -z "$VIRTUAL_ENV" ]; then
36 echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n $GECKODRIVER_URL"
37 exit
38 else
39 echo "Installing $VIRTUAL_ENV from\n $GECKODRIVER_URL"
40 FILE=`mktemp`
41 wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C $VIRTUAL_ENV/bin/ -f $FILE geckodriver
42 rm $FILE
43 chmod 777 $VIRTUAL_ENV/bin/geckodriver
44 fi
47pep8_check() {
48 echo '[!] Running pep8 check'
49 # ignored rules:
50 # E402 module level import not at top of file
51 # W503 line break before binary operator
52 pep8 --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests"
55unit_tests() {
56 echo '[!] Running unit tests'
57 python -m nose2 -s "$BASE_DIR/tests/unit"
60py_test_coverage() {
61 echo '[!] Running python test coverage'
62 PYTHONPATH=`pwd` python -m nose2 -C --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit"
63 coverage report
64 coverage html
67robot_tests() {
68 echo '[!] Running robot tests'
69 PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot
72tests() {
73 set -e
74 pep8_check
75 unit_tests
76 check_geckodriver
77 robot_tests
78 set +e
81build_style() {
82 lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
85styles() {
86 echo '[!] Building styles'
87 build_style themes/legacy/less/style.less themes/legacy/css/style.css
88 build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
89 build_style themes/courgette/less/style.less themes/courgette/css/style.css
90 build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
91 build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
92 build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
93 build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
94 build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
97grunt_build() {
98 grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
101locales() {
102 pybabel compile -d "$SEARX_DIR/translations"
105help() {
106 [ -z "$1" ] || printf "Error: $1\n"
107 echo "Searx manage.sh help
109Commands
110========
111 grunt_build - Build js files
112 help - This text
113 locales - Compile locales
114 pep8_check - Pep8 validation
115 py_test_coverage - Unit test coverage
116 robot_tests - Run selenium tests
117 styles - Build less files
118 tests - Run all python tests (pep8, unit, robot)
119 unit_tests - Run unit tests
120 update_dev_packages - Check & update development and production dependency changes
121 update_packages - Check & update dependency changes
122 check_geckodriver - Check & download geckodriver (required for robot_tests)
126[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
127 && help "action not found" \
128 || $ACTION