manage.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/oscar/oscar.less themes/oscar/css/oscar.min.css
  52. build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
  53. }
  54. grunt_build() {
  55. grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
  56. }
  57. locales() {
  58. pybabel compile -d "$SEARX_DIR/translations"
  59. }
  60. help() {
  61. [ -z "$1" ] || echo "Error: $1\n"
  62. echo "Searx manage.sh help
  63. Commands
  64. ========
  65. grunt_build - Build js files
  66. help - This text
  67. locales - Compile locales
  68. pep8_check - Pep8 validation
  69. py_test_coverage - Unit test coverage
  70. robot_tests - Run selenium tests
  71. styles - Build less files
  72. tests - Run all python tests (pep8, unit, robot)
  73. unit_tests - Run unit tests
  74. update_dev_packages - Check & update development and production dependency changes
  75. update_packages - Check & update dependency changes
  76. "
  77. }
  78. if type $ACTION 1>/dev/null; then
  79. $ACTION
  80. else
  81. help "action not found"
  82. fi