diff --git a/pyrosrun.sh b/pyrosrun.sh index a985cb5..1afb549 100755 --- a/pyrosrun.sh +++ b/pyrosrun.sh @@ -12,7 +12,9 @@ COMMANDS="\n \t'start' : Starts the simulators then the celery workers, then the web server\n \t'stop' : Stops the celery workers then the simulators\n \t'clean_logs' : Clear all pyros .log files from /logs\n -\t'simulator' : Launch routine simulator\n" +\t'simulator' : Launch routine simulator\n +\t'kill_simulation : Kill web server and celery tasks (only use during simulation)'\n +\t'sim : start only simulation task'" #\t'test_runserver' : Launch web server on test database NEEDED_COMMAND="One command is needed. Possible commands : $COMMANDS" @@ -89,6 +91,9 @@ case "$1" in "kill_simulation") scripts/kill_simulation.sh ;; + "sim") + celery worker -A pyros -Q simulator_q -n pyros@simulator -c 1 & + ;; *) echo -e $INVALID_COMMAND ;; diff --git a/src/pyros/settings.py b/src/pyros/settings.py index 81946f3..4aeb02b 100644 --- a/src/pyros/settings.py +++ b/src/pyros/settings.py @@ -121,8 +121,8 @@ LOGIN_URL = "/" CELERY_TEST = False -if CELERY_TEST == False: - if MYSQL == False: +if not CELERY_TEST: + if not MYSQL: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', diff --git a/src/simulator/tasks.py b/src/simulator/tasks.py index 6b41eea..2bc1e13 100644 --- a/src/simulator/tasks.py +++ b/src/simulator/tasks.py @@ -10,7 +10,60 @@ import time log = l.setupLogger("simulator", "simulator") +class SimulatorRoutines(): + def __init__(self, quantity, dtime): + self.quantity = quantity + self.dtime = dtime + log.info("SimulatorRoutines class instantiated with %d routines to be executed with an interval of time %d"%(quantity,dtime)) + + # First create some scientific programs + def createScientificPrograms(self): + pass + + # create some user levels with diferent priorities + def createUserLevels(self): + pass + + # create some pyros users + def createPyrosUsers(self, country, user_id, user_level_id): + pass + + # create auth users + def createAuthUsers(self): + + # You can now create Requests + def createRequest(self, pyros_user_id, scientific_program_id): + pass + + # requests must have sequences + def createSequences(self, request): + pass + + # Sequences must have albums + def createAlbums(self, sequence): + pass + + # albums must have plans + def createPlans(self, album): + pass + + def process(self): + pass + + class simulator(Task): + shouldClean = False + def run(self): - log.info("Simulator run function") - os.system("%s/../pyrosrun.sh kill_simulation"%settings.BASE_DIR) + simu = SimulatorRoutines(100, 2) + # for schedule in py_schedules: + + + # END OF EXECTUION (KILLING WEB SERVER AN PROCESS) + if (self.shouldClean == True): + os.system("%s/../pyrosrun.sh kill_simulation"%settings.BASE_DIR) + +if __name__ == "__main__": + sim = simulator(Task) + sim.shouldClean = False + sim.run() -- libgit2 0.21.2