manage.sh 2.6KB

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