manage.sh 2.4KB

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