on chiefr-integration help sign in
searx/manage.sh
159 lines 5.0 kB history raw
1#!/bin/sh
3BASE_DIR=$(dirname "`readlink -f "$0"`")
4PYTHONPATH=$BASE_DIR
5SEARX_DIR="$BASE_DIR/searx"
6ACTION=$1
8cd "$BASE_DIR"
10update_packages() {
11 pip install --upgrade pip
12 pip install --upgrade setuptools
13 pip install -r "$BASE_DIR/requirements.txt"
16update_dev_packages() {
17 update_packages
18 pip install -r "$BASE_DIR/requirements-dev.txt"
21install_geckodriver() {
22 echo '[!] Checking geckodriver'
23 # TODO : check the current geckodriver version
24 set -e
25 geckodriver -V 2>1 > /dev/null || NOTFOUND=1
26 set +e
27 if [ -z $NOTFOUND ]; then
28 return
29 fi
30 GECKODRIVER_VERSION="v0.18.0"
31 PLATFORM=`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`
32 case $PLATFORM in
33 "linux 32bit" | "linux2 32bit") ARCH="linux32";;
34 "linux 64bit" | "linux2 64bit") ARCH="linux64";;
35 "windows 32 bit") ARCH="win32";;
36 "windows 64 bit") ARCH="win64";;
37 "mac 64bit") ARCH="macos";;
38 esac
39 GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
41 if [ -z "$1" ]; then
42 if [ -z "$VIRTUAL_ENV" ]; then
43 echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n $GECKODRIVER_URL"
44 exit
45 else
46 GECKODRIVER_DIR="$VIRTUAL_ENV/bin"
47 fi
48 else
49 GECKODRIVER_DIR="$1"
50 mkdir -p "$GECKODRIVER_DIR"
51 fi
53 echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL"
55 FILE=`mktemp`
56 wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C "$GECKODRIVER_DIR" -f $FILE geckodriver
57 rm $FILE
58 chmod 777 "$GECKODRIVER_DIR/geckodriver"
61pep8_check() {
62 echo '[!] Running pep8 check'
63 # ignored rules:
64 # E402 module level import not at top of file
65 # W503 line break before binary operator
66 pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests"
69unit_tests() {
70 echo '[!] Running unit tests'
71 python -m nose2 -s "$BASE_DIR/tests/unit"
74py_test_coverage() {
75 echo '[!] Running python test coverage'
76 PYTHONPATH=`pwd` python -m nose2 -C --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit"
77 coverage report
78 coverage html
81robot_tests() {
82 echo '[!] Running robot tests'
83 PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot
86tests() {
87 set -e
88 pep8_check
89 unit_tests
90 install_geckodriver
91 robot_tests
92 set +e
95build_style() {
96 lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
99styles() {
100 echo '[!] Building styles'
101 build_style themes/legacy/less/style.less themes/legacy/css/style.css
102 build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
103 build_style themes/courgette/less/style.less themes/courgette/css/style.css
104 build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
105 build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
106 build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
107 # built using grunt
108 #build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
109 #build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
110 #build_style themes/simple/less/style.less themes/simple/css/searx.min.css
111 #build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
114npm_packages() {
115 echo '[!] install NPM packages for oscar theme'
116 cd $BASE_DIR/searx/static/themes/oscar
117 npm install
119 echo '[!] install NPM packages for simple theme'
120 cd $BASE_DIR/searx/static/themes/simple
121 npm install
124grunt_build() {
125 echo '[!] Grunt build : oscar theme'
126 grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
127 echo '[!] Grunt build : simple theme'
128 grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
131locales() {
132 pybabel compile -d "$SEARX_DIR/translations"
135help() {
136 [ -z "$1" ] || printf "Error: $1\n"
137 echo "Searx manage.sh help
139Commands
140========
141 npm_packages - Download & install dependencies
142 grunt_build - Build js files
143 help - This text
144 locales - Compile locales
145 pep8_check - Pep8 validation
146 py_test_coverage - Unit test coverage
147 robot_tests - Run selenium tests
148 styles - Build less files
149 tests - Run all python tests (pep8, unit, robot)
150 unit_tests - Run unit tests
151 update_dev_packages - Check & update development and production dependency changes
152 update_packages - Check & update dependency changes
153 install_geckodriver - Download & install geckodriver if not already installed (required for robot_tests)
157[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
158 && help "action not found" \
159 || $ACTION "$2"