manage.sh 2.4KB

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