Scripts

Explanations about the scripts.


Most of them are located in src/scripts/ folder :

celery_test.sh / .bat

  • Goal
    Run tests using the production database in order to see the celery results (celery is always running on production database).
  • Argument(s)
    You need to give the app / TestClass / test_name to run it (prevents a fail test launching, polluting the production DB)
  • How it works ?
    • Uses sed command to set CELERY_TEST variable to 'True' in settings.py (The consequence is that the production DB will be chosen for tests in settings.py)
    • Creates a fresh test sqlite database, and populate it with misc/fixtures/initial_fixtures.json
    • Starts the simulators, then celery
    • Runs the test(s) you gave with --keepdb and --nomigrations
    • Stops the simulators and celery workers

delete_all_request.sh

  • Goal
    Deletes all the Alerts, Requests, Sequences, Albums and Plan from the current DB (the one chosen in settings.py)
    The goal is to easily clean the DB
  • How it works ?
    • Moves to src/ folder
    • Checks in settings.py whether MySQL or SQLite is used
    • Uses SQL inline command to delete the fields in the current DB

kill_celery_workers.sh / .bat

  • Goal
    Deletes all the celery workers running (in background, or not)
  • How it works ?
    • Lists all the process running on the computer
    • Looks for "celery worker" matching one
    • Gets their PIDs
    • Send them a kill -9 message

start_celery_worker.sh / .bat

  • Goal
    Starts the celery workers, giving them a queue and a name
  • How it works ?
    • Moves to src/ folder
    • Kills the workers still running
    • Starts every worker one by one (in background using '&'), giving them a queue, a name, and purging the associated queue if needed

test_all_usual.sh / .bat

  • Goal
    Run all the tests that don't need celery
  • How it works ?
    • Just use python manage.py test command with all the wanted tests

They are also two scripts in the simulators/ folder :

run_all.sh

  • Goal
    Run all the simulators in background
  • How it works ?
    • Launches each simulator in background with python

kill_all.sh

  • Goal
    Kill all simulators process in background
  • How it works ?
    • Finds the process IDs corresponding to the simulators and kills them

The script that should be used by users to run the project's functionalities is in the PYROS/ root folder :

pyrosrun.sh / .bat

  • Goal
    Allow to run every feature of the project from its root (runserver, tests, celery, ...)
  • How it works ?
    • It calls the manage.py commands and the other scripts, according to the given parameters (see the usage message) <== This script should be improved before the 12/08/2016
  • Possible commands :
    • 'server' : Runs the web server
    • 'updatedb' : Update the database
    • 'unittest' : Runs the tests that don't need celery
    • 'test_all' : Run all the existing tests (this command needs to be updated when tests are added in the project)
    • 'celery_on' : Starts the celery workers
    • 'celery_off' : Stops the celery workers
    • 'simul_on' : Starts the simulators
    • 'simul_off' : Stops the simulators
    • 'start' : Starts the simulators then the celery workers, then the web server
    • 'stop' : Stops the celery workers then the simulators