Commit 05bdcc44d371fe7727b75c7b57e331787abab77f

Authored by Etienne Pallier
1 parent cd0149f5
Exists in dev

BIG DEMO tests (simulator and simulator_development) pass WITH celery and PARTIA…

…LLY WITHOUT (./pyros.py simulator)

BON, LA FAUT VRAIMENT QUE J'ARRETE DE CODER, JE VAIS Y LAISSER MA PEAU...
!!!!!!!!!!!!!!!! FAUT QUE JE PASSE A LA DOC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -62,11 +62,11 @@ PROJECT STRUCTURE: @@ -62,11 +62,11 @@ PROJECT STRUCTURE:
62 -------------------------------------------------------------------------------------------- 62 --------------------------------------------------------------------------------------------
63 LAST VERSION 63 LAST VERSION
64 64
65 -Date: 23/03/2018 65 +Date: 27/03/2018
66 By: E. Pallier 66 By: E. Pallier
67 -Version: 0.16.11  
68 -- All unit tests now pass WITHOUT celery (./manage.py test or ./pyros.py test) :  
69 -it needed a bugfix on the json fixture !! (the pyrosuser quota was null : set it to 100) 67 +Version: 0.16.12
  68 +- BIG DEMO tests (simulator and simulator_development) pass WITH celery and PARTIALLY WITHOUT (./pyros.py simulator)
  69 +- All unit tests pass WITH or WITHOUT celery (./manage.py test or ./pyros.py test)
70 - New global variable USE_CELERY (false by default) in pyros.settings 70 - New global variable USE_CELERY (false by default) in pyros.settings
71 - README file in each module (with version 0.1.0) 71 - README file in each module (with version 0.1.0)
72 - each agent (envmonitor, majordome, alert) can be started independently with a script (new script start_agent in each agent directory) 72 - each agent (envmonitor, majordome, alert) can be started independently with a script (new script start_agent in each agent directory)
@@ -645,6 +645,15 @@ class Pyros(AManager): @@ -645,6 +645,15 @@ class Pyros(AManager):
645 def simulator_development(self): 645 def simulator_development(self):
646 self.simulator(False) 646 self.simulator(False)
647 647
  648 + '''
  649 + (EP) utile pour le debug avec phpmyadmin pour remettre à zéro la bd pyros_test
  650 + delete from plan;
  651 + delete from album;
  652 + delete from schedule_has_sequences;
  653 + delete from schedule;
  654 + delete from sequence;
  655 + delete from request;
  656 + '''
648 657
649 # Simulation (by default, with ALL simulators and ALL celery workers) 658 # Simulation (by default, with ALL simulators and ALL celery workers)
650 def simulator(self, TOTAL=True): 659 def simulator(self, TOTAL=True):
@@ -660,6 +669,8 @@ class Pyros(AManager): @@ -660,6 +669,8 @@ class Pyros(AManager):
660 else : self.execProcess("rm -f testdb.sqlite3") 669 else : self.execProcess("rm -f testdb.sqlite3")
661 self.changeDirectory("..") 670 self.changeDirectory("..")
662 if TOTAL: self.reset_database_sim() 671 if TOTAL: self.reset_database_sim()
  672 + # EP added:
  673 + if not TOTAL: self.reset_database_sim()
663 674
664 # Actualise l’état de la DB en accord avec l’ensemble des modèles et des migrations actuels 675 # Actualise l’état de la DB en accord avec l’ensemble des modèles et des migrations actuels
665 self.migrate() 676 self.migrate()
@@ -727,6 +738,17 @@ class Pyros(AManager): @@ -727,6 +738,17 @@ class Pyros(AManager):
727 self.changeDirectory("..") 738 self.changeDirectory("..")
728 ''' 739 '''
729 740
  741 + #
  742 + # 4) (if not USE_CELERY) Start Agents
  743 + #
  744 + # TODO:
  745 + if TOTAL and not USE_CELERY :
  746 + # Start Environment Monitoring Agent
  747 + # Start Majordome Agent
  748 + # Start Alert Manager Agent
  749 + self.start_agents()
  750 + self.sleep(3)
  751 +
730 # When simulators are finished: 752 # When simulators are finished:
731 #self.kill_simulation() 753 #self.kill_simulation()
732 return 0 754 return 0
simulators/user/userSimulator.py
@@ -47,7 +47,7 @@ class UserSimulator(): @@ -47,7 +47,7 @@ class UserSimulator():
47 47
48 def sendRequest(self, file_name: str): 48 def sendRequest(self, file_name: str):
49 files = {'request_file' : open(self.request_path + file_name, 'rb')} 49 files = {'request_file' : open(self.request_path + file_name, 'rb')}
50 - print("Post request", self.url, "with args", files) 50 + #print("Post request", self.url, "with args", files)
51 # ex: Post request http://localhost:8000/routine_manager/import_request with args {'request_file': <_io.BufferedReader name='../resources/routine_request_01.xml'>} 51 # ex: Post request http://localhost:8000/routine_manager/import_request with args {'request_file': <_io.BufferedReader name='../resources/routine_request_01.xml'>}
52 # This calls import_request() action from src/routine_manager/views.py 52 # This calls import_request() action from src/routine_manager/views.py
53 r = self.client.post(self.url, files=files) 53 r = self.client.post(self.url, files=files)
src/common/models.py
@@ -554,6 +554,7 @@ class Sequence(models.Model): @@ -554,6 +554,7 @@ class Sequence(models.Model):
554 554
555 555
556 class ScheduleHasSequences(models.Model): 556 class ScheduleHasSequences(models.Model):
  557 + # (EP) TODO: C'est pas un pb d'utiliser 2 fois le meme nom "shs" pour 2 choses differentes ???!!!
557 schedule = models.ForeignKey( 558 schedule = models.ForeignKey(
558 'Schedule', on_delete=models.CASCADE, related_name="shs") 559 'Schedule', on_delete=models.CASCADE, related_name="shs")
559 sequence = models.ForeignKey( 560 sequence = models.ForeignKey(
src/majordome/tasks.py
@@ -177,6 +177,8 @@ class Majordome(Task): @@ -177,6 +177,8 @@ class Majordome(Task):
177 Function called by the main loop to handle the task event (check monitoring and alert_manager) 177 Function called by the main loop to handle the task event (check monitoring and alert_manager)
178 ''' 178 '''
179 def handleTasks(self): 179 def handleTasks(self):
  180 + if not settings.USE_CELERY: return 0
  181 +
180 self.timers["tasks"] = self.tasks_timer 182 self.timers["tasks"] = self.tasks_timer
181 if self.monitoring_task is None: 183 if self.monitoring_task is None:
182 try: 184 try:
@@ -306,7 +308,14 @@ class Majordome(Task): @@ -306,7 +308,14 @@ class Majordome(Task):
306 def handleNightEndTimer(self): 308 def handleNightEndTimer(self):
307 self.timers["night_end"] = getNightEnd() 309 self.timers["night_end"] = getNightEnd()
308 if (self.isValidStatus(self.status_tel)): 310 if (self.isValidStatus(self.status_tel)):
309 - observation_manager.tasks.night_calibrations.apply_async() 311 + #observation_manager.tasks.night_calibrations.apply_async()
  312 + if settings.USE_CELERY:
  313 + print("MJ: call observation_manager WITH CELERY")
  314 + observation_manager.tasks.night_calibrations.apply_async()
  315 + else:
  316 + print("MJ: call observation_manager WITHOUT CELERY")
  317 + observation_manager.tasks.night_calibrations().run()
  318 +
310 else: 319 else:
311 self.notifyTelescopeStatus("night_end") 320 self.notifyTelescopeStatus("night_end")
312 return (0) 321 return (0)
@@ -320,7 +329,14 @@ class Majordome(Task): @@ -320,7 +329,14 @@ class Majordome(Task):
320 self.dom.open() 329 self.dom.open()
321 self.vis_camera.open_shutter() 330 self.vis_camera.open_shutter()
322 self.nir_camera.open_shutter() 331 self.nir_camera.open_shutter()
323 - scheduler.tasks.scheduling.apply_async((False, False)) 332 + #scheduler.tasks.scheduling.apply_async((False, False))
  333 + if settings.USE_CELERY:
  334 + print("MJ: call schedule WITH CELERY")
  335 + scheduler.tasks.scheduling.apply_async((False, False))
  336 + else:
  337 + print("MJ: call schedule WITHOUT CELERY")
  338 + scheduler.tasks.scheduling().run((False, False))
  339 +
324 return (0) 340 return (0)
325 341
326 def notifyTelescopeStatus(self, timer_name): 342 def notifyTelescopeStatus(self, timer_name):
@@ -388,9 +404,22 @@ class Majordome(Task): @@ -388,9 +404,22 @@ class Majordome(Task):
388 def reset(self, type): 404 def reset(self, type):
389 if type == "WEATHER": 405 if type == "WEATHER":
390 self.dom.open() 406 self.dom.open()
391 - scheduler.tasks.scheduling.delay((False, False)) 407 + #scheduler.tasks.scheduling.delay((False, False))
  408 + if settings.USE_CELERY:
  409 + print("MJ: call schedule WITH CELERY")
  410 + scheduler.tasks.scheduling.delay((False, False))
  411 + else:
  412 + print("MJ: call schedule WITHOUT CELERY")
  413 + scheduler.tasks.scheduling().run((False, False))
  414 +
392 elif type == "INSIDE": 415 elif type == "INSIDE":
393 - scheduler.tasks.scheduling.delay((False, False)) 416 + #scheduler.tasks.scheduling.delay((False, False))
  417 + if settings.USE_CELERY:
  418 + print("MJ: call schedule WITH CELERY")
  419 + scheduler.tasks.scheduling.delay((False, False))
  420 + else:
  421 + print("MJ: call schedule WITHOUT CELERY")
  422 + scheduler.tasks.scheduling().run((False, False))
394 423
395 ''' 424 '''
396 Handle a new alarm (called by isInsideOk or isWeatherOk) 425 Handle a new alarm (called by isInsideOk or isWeatherOk)
@@ -485,8 +514,16 @@ class Majordome(Task): @@ -485,8 +514,16 @@ class Majordome(Task):
485 if sequence.albums.filter(detector__name="Cagire").exists(): 514 if sequence.albums.filter(detector__name="Cagire").exists():
486 if (self.isValidStatus(self.status_nir)): 515 if (self.isValidStatus(self.status_nir)):
487 for plan in sequence.albums.get(detector__name="Cagire").plans.all(): 516 for plan in sequence.albums.get(detector__name="Cagire").plans.all():
488 - res = observation_manager.tasks.execute_plan_nir.apply_async(  
489 - (plan.id, float(self.getCountdown(shs)))) 517 + #res = observation_manager.tasks.execute_plan_nir.apply_async((plan.id, float(self.getCountdown(shs))))
  518 + if settings.USE_CELERY:
  519 + print("MJ: call observation_manager WITH CELERY")
  520 + res = observation_manager.tasks.execute_plan_nir.apply_async(
  521 + (plan.id, float(self.getCountdown(shs))))
  522 + else:
  523 + print("MJ: call observation_manager WITHOUT CELERY")
  524 + res = observation_manager.tasks.execute_plan_nir().run(
  525 + (plan.id, float(self.getCountdown(shs))))
  526 +
490 # JB TODO : is it still usefull ? 527 # JB TODO : is it still usefull ?
491 # TaskId.objects.create(task_id=res.id, task="execute_plan") 528 # TaskId.objects.create(task_id=res.id, task="execute_plan")
492 plans_results.append(res) 529 plans_results.append(res)
@@ -500,8 +537,14 @@ class Majordome(Task): @@ -500,8 +537,14 @@ class Majordome(Task):
500 if sequence.albums.filter(detector__name="Visible camera").exists(): 537 if sequence.albums.filter(detector__name="Visible camera").exists():
501 if (self.isValidStatus(self.status_vis)): 538 if (self.isValidStatus(self.status_vis)):
502 for plan in sequence.albums.get(detector__name="Visible camera").plans.all(): 539 for plan in sequence.albums.get(detector__name="Visible camera").plans.all():
503 - res = observation_manager.tasks.execute_plan_vis.apply_async(  
504 - (plan.id, float(self.getCountdown(shs)))) 540 + #res = observation_manager.tasks.execute_plan_vis.apply_async((plan.id, float(self.getCountdown(shs))))
  541 + if settings.USE_CELERY:
  542 + print("MJ: call observation_manager WITH CELERY")
  543 + res = observation_manager.tasks.execute_plan_vis.apply_async((plan.id, float(self.getCountdown(shs))))
  544 + else:
  545 + print("MJ: call observation_manager WITHOUT CELERY")
  546 + res = observation_manager.tasks.execute_plan_vis().run((plan.id, float(self.getCountdown(shs))))
  547 +
505 plans_results.append(res) 548 plans_results.append(res)
506 else: 549 else:
507 self.notifyDeviceStatus("Camera visible", "Sequence execution", self.status_vis) 550 self.notifyDeviceStatus("Camera visible", "Sequence execution", self.status_vis)
@@ -583,7 +626,14 @@ class Majordome(Task): @@ -583,7 +626,14 @@ class Majordome(Task):
583 def systemPause(self, duration, cause: str): 626 def systemPause(self, duration, cause: str):
584 self.logDB("System in pause for " + str(duration)) 627 self.logDB("System in pause for " + str(duration))
585 time.sleep(duration) 628 time.sleep(duration)
586 - scheduler.tasks.scheduling.apply_async(first_schedule=False, alert=False) 629 + #scheduler.tasks.scheduling.apply_async(first_schedule=False, alert=False)
  630 + if settings.USE_CELERY:
  631 + print("MJ: call schedule WITH CELERY")
  632 + scheduler.tasks.scheduling.apply_async(first_schedule=False, alert=False)
  633 + else:
  634 + print("MJ: call schedule WITHOUT CELERY")
  635 + scheduler.tasks.scheduling().run(first_schedule=False, alert=False)
  636 +
587 self.setTime() 637 self.setTime()
588 print("system has been paused. Cause : " + cause) 638 print("system has been paused. Cause : " + cause)
589 return (0) 639 return (0)
src/misc/fixtures/initial_fixture_noTZ.json 0 → 100644
@@ -0,0 +1,497 @@ @@ -0,0 +1,497 @@
  1 +[
  2 +{
  3 + "model": "common.country",
  4 + "pk": 1,
  5 + "fields": {
  6 + "name": "France",
  7 + "desc": "",
  8 + "quota": null
  9 + }
  10 +},
  11 +{
  12 + "model": "common.detector",
  13 + "pk": 1,
  14 + "fields": {
  15 + "telescope": 1,
  16 + "status": "",
  17 + "nb_photo_x": null,
  18 + "nb_photo_y": null,
  19 + "photo_size_x": null,
  20 + "photo_size_y": null,
  21 + "has_shutter": false,
  22 + "equivalent_foc_len": "",
  23 + "acq_start": null,
  24 + "acq_stop": null,
  25 + "check_temp": null,
  26 + "gain": null,
  27 + "readout_noise": null,
  28 + "readout_time": null,
  29 + "idcam_readout_mode": null,
  30 + "name": "Cagire",
  31 + "desc": "",
  32 + "created": "2016-05-13 11:49:49",
  33 + "updated": "2016-05-13 11:49:49",
  34 + "is_online": false,
  35 + "maintenance_date": null
  36 + }
  37 +},
  38 +{
  39 + "model": "common.detector",
  40 + "pk": 2,
  41 + "fields": {
  42 + "telescope": 1,
  43 + "nb_photo_x": null,
  44 + "nb_photo_y": null,
  45 + "photo_size_x": null,
  46 + "photo_size_y": null,
  47 + "has_shutter": false,
  48 + "equivalent_foc_len": "",
  49 + "acq_start": null,
  50 + "acq_stop": null,
  51 + "check_temp": null,
  52 + "gain": null,
  53 + "readout_noise": null,
  54 + "readout_time": null,
  55 + "idcam_readout_mode": null,
  56 + "name": "Visible camera",
  57 + "desc": "",
  58 + "created": "2016-05-13 11:50:17",
  59 + "updated": "2016-05-13 11:50:17",
  60 + "is_online": false,
  61 + "status": "",
  62 + "maintenance_date": null
  63 + }
  64 +},
  65 +{
  66 + "model": "common.plc",
  67 + "pk": 1,
  68 + "fields": {
  69 + "last_update_status": null,
  70 + "name": "Plc",
  71 + "desc": "",
  72 + "created": "2016-05-13 11:50:14",
  73 + "updated": "2016-05-13 11:50:14",
  74 + "is_online": false,
  75 + "maintenance_date": null
  76 + }
  77 +},
  78 +{
  79 + "model": "common.filter",
  80 + "pk": 1,
  81 + "fields": {
  82 + "filter_wheel": 2,
  83 + "category": "",
  84 + "transmission_curve_doc": "",
  85 + "name": "First infrared filter",
  86 + "desc": "",
  87 + "created": "2016-05-13 11:49:56",
  88 + "updated": "2016-05-13 11:49:56",
  89 + "is_online": false,
  90 + "status": "",
  91 + "maintenance_date": null
  92 + }
  93 +},
  94 +{
  95 + "model": "common.filter",
  96 + "pk": 2,
  97 + "fields": {
  98 + "filter_wheel": 2,
  99 + "category": "",
  100 + "transmission_curve_doc": "",
  101 + "name": "Second infrared filter",
  102 + "desc": "",
  103 + "created": "2016-05-13 11:50:07",
  104 + "updated": "2016-05-13 11:50:07",
  105 + "is_online": false,
  106 + "status": "",
  107 + "maintenance_date": null
  108 + }
  109 +},
  110 +{
  111 + "model": "common.filter",
  112 + "pk": 3,
  113 + "fields": {
  114 + "filter_wheel": 2,
  115 + "category": "",
  116 + "transmission_curve_doc": "",
  117 + "name": "First visible filter",
  118 + "desc": "",
  119 + "created": "2016-05-13 11:50:02",
  120 + "updated": "2016-05-13 11:50:02",
  121 + "is_online": false,
  122 + "status": "",
  123 + "maintenance_date": null
  124 + }
  125 +},
  126 +{
  127 + "model": "common.filter",
  128 + "pk": 4,
  129 + "fields": {
  130 + "filter_wheel": 2,
  131 + "category": "",
  132 + "transmission_curve_doc": "",
  133 + "name": "Second visible filter",
  134 + "desc": "",
  135 + "created": "2016-05-13 11:50:11",
  136 + "updated": "2016-05-13 11:50:11",
  137 + "is_online": false,
  138 + "status": "",
  139 + "maintenance_date": null
  140 + }
  141 +},
  142 +{
  143 + "model": "common.filterwheel",
  144 + "pk": 1,
  145 + "fields": {
  146 + "detector": 1,
  147 + "name": "Cagire FW",
  148 + "desc": "",
  149 + "created": "2016-06-28 13:28:28",
  150 + "updated": "2016-06-28 13:28:28",
  151 + "is_online": false,
  152 + "status": "",
  153 + "maintenance_date": null
  154 + }
  155 +},
  156 +{
  157 + "model": "common.filterwheel",
  158 + "pk": 2,
  159 + "fields": {
  160 + "detector": 2,
  161 + "name": "Visible Camera FW",
  162 + "desc": "",
  163 + "created": "2016-06-28 13:28:46",
  164 + "updated": "2016-06-28 13:28:46",
  165 + "is_online": false,
  166 + "status": "",
  167 + "maintenance_date": null
  168 + }
  169 +},
  170 +{
  171 + "model": "common.scientificprogram",
  172 + "pk": 1,
  173 + "fields": {
  174 + "name": "GRB",
  175 + "desc": "",
  176 + "quota": 9999.0,
  177 + "priority": 0,
  178 + "pyros_users": [
  179 + 5
  180 + ]
  181 + }
  182 +},
  183 +{
  184 + "model": "common.strategyobs",
  185 + "pk": 1,
  186 + "fields": {
  187 + "name": "strat1",
  188 + "desc": "",
  189 + "xml_file": "strat1.xml",
  190 + "is_default": false
  191 + }
  192 +},
  193 +{
  194 + "model": "common.strategyobs",
  195 + "pk": 2,
  196 + "fields": {
  197 + "name": "strat2",
  198 + "desc": "",
  199 + "xml_file": "strat2.xml",
  200 + "is_default": false
  201 + }
  202 +},
  203 +{
  204 + "model": "common.strategyobs",
  205 + "pk": 3,
  206 + "fields": {
  207 + "name": "strat_unittest",
  208 + "desc": "",
  209 + "xml_file": "strat_unittest.xml",
  210 + "is_default": true
  211 + }
  212 +},
  213 +{
  214 + "model": "common.telescope",
  215 + "pk": 1,
  216 + "fields": {
  217 + "mount_type": "",
  218 + "diameter": null,
  219 + "status": "",
  220 + "latitude": null,
  221 + "longitude": null,
  222 + "sens": "",
  223 + "altitude": null,
  224 + "readout_time": null,
  225 + "slew_time": null,
  226 + "slew_dead": null,
  227 + "slew_rate_max": null,
  228 + "horizon_type": "",
  229 + "horizon_def": null,
  230 + "lim_dec_max": null,
  231 + "lim_dec_min": null,
  232 + "lim_ha_rise": null,
  233 + "lim_ha_set": null,
  234 + "address": "",
  235 + "night_elev_sun": null,
  236 + "mpc_code": "",
  237 + "name": "Telescope",
  238 + "desc": "",
  239 + "created": "2016-05-13 11:50:14",
  240 + "updated": "2016-05-13 11:50:14",
  241 + "is_online": false,
  242 + "maintenance_date": null
  243 + }
  244 +},
  245 +{
  246 + "model": "common.dome",
  247 + "pk": 1,
  248 + "fields": {
  249 + "name": "Dome",
  250 + "desc": "dome",
  251 + "created": "2016-05-13 11:50:14",
  252 + "updated": "2016-05-13 11:50:14",
  253 + "is_online": false,
  254 + "status": "",
  255 + "maintenance_date": null,
  256 + "open": false
  257 + }
  258 +},
  259 +{
  260 + "model": "common.userlevel",
  261 + "pk": 1,
  262 + "fields": {
  263 + "name": "Developer",
  264 + "desc": "",
  265 + "priority": 0,
  266 + "quota": 9999.0
  267 + }
  268 +},
  269 +{
  270 + "model": "common.version",
  271 + "pk": 1,
  272 + "fields": {
  273 + "module_name": "Scheduler",
  274 + "version": "0.1",
  275 + "created": "2016-06-23 14:04:48",
  276 + "updated": "2016-06-23 14:04:48"
  277 + }
  278 +},
  279 +{
  280 + "model": "common.version",
  281 + "pk": 2,
  282 + "fields": {
  283 + "module_name": "Dashboard",
  284 + "version": "0.1",
  285 + "created": "2016-06-23 14:04:48",
  286 + "updated": "2016-06-23 14:04:48"
  287 + }
  288 +},
  289 +{
  290 + "model": "common.version",
  291 + "pk": 3,
  292 + "fields": {
  293 + "module_name": "Observation Manager",
  294 + "version": "0.1",
  295 + "created": "2016-06-23 14:04:48",
  296 + "updated": "2016-06-23 14:04:48"
  297 + }
  298 +},
  299 +{
  300 + "model": "common.version",
  301 + "pk": 4,
  302 + "fields": {
  303 + "module_name": "Routine Manager",
  304 + "version": "0.1",
  305 + "created": "2016-06-23 14:04:48",
  306 + "updated": "2016-06-23 14:04:48"
  307 + }
  308 +},
  309 +{
  310 + "model": "common.version",
  311 + "pk": 5,
  312 + "fields": {
  313 + "module_name": "Alert Manager",
  314 + "version": "0.1",
  315 + "created": "2016-06-23 14:04:48",
  316 + "updated": "2016-06-23 14:04:48"
  317 + }
  318 +},
  319 +{
  320 + "model": "common.version",
  321 + "pk": 6,
  322 + "fields": {
  323 + "module_name": "Monitoring",
  324 + "version": "0.1",
  325 + "created": "2016-06-23 14:04:48",
  326 + "updated": "2016-06-23 14:04:48"
  327 + }
  328 +},
  329 +{
  330 + "model": "common.version",
  331 + "pk": 7,
  332 + "fields": {
  333 + "module_name": "User Manager",
  334 + "version": "0.1",
  335 + "created": "2016-06-23 14:04:48",
  336 + "updated": "2016-06-23 14:04:48"
  337 + }
  338 +},
  339 +{
  340 + "model": "common.version",
  341 + "pk": 8,
  342 + "fields": {
  343 + "module_name": "Analyzer",
  344 + "version": "0.1",
  345 + "created": "2016-06-23 14:04:48",
  346 + "updated": "2016-06-23 14:04:48"
  347 + }
  348 +},
  349 +{
  350 + "model": "common.version",
  351 + "pk": 9,
  352 + "fields": {
  353 + "module_name": "Majordome",
  354 + "version": "0.1",
  355 + "created": "2016-06-23 14:04:48",
  356 + "updated": "2016-06-23 14:04:48"
  357 + }
  358 +},
  359 +{
  360 + "model": "common.version",
  361 + "pk": 10,
  362 + "fields": {
  363 + "module_name": "Majordome",
  364 + "version": "0.2",
  365 + "created": "2016-06-28 10:50:32",
  366 + "updated": "2016-06-28 10:50:32"
  367 + }
  368 +},
  369 +{
  370 + "model": "common.version",
  371 + "pk": 11,
  372 + "fields": {
  373 + "module_name": "Majordome",
  374 + "version": "0.1.4",
  375 + "created": "2016-07-20 13:44:29",
  376 + "updated": "2016-07-20 13:44:29"
  377 + }
  378 +},
  379 +{
  380 + "model": "common.version",
  381 + "pk": 12,
  382 + "fields": {
  383 + "module_name": "Alert Manager",
  384 + "version": "0.2.3",
  385 + "created": "2016-07-20 13:44:29",
  386 + "updated": "2016-07-20 13:44:29"
  387 + }
  388 +},
  389 +{
  390 + "model": "common.version",
  391 + "pk": 13,
  392 + "fields": {
  393 + "module_name": "Dashboard",
  394 + "version": "0.1.1",
  395 + "created": "2016-07-20 13:44:29",
  396 + "updated": "2016-07-20 13:44:29"
  397 + }
  398 +},
  399 +{
  400 + "model": "common.version",
  401 + "pk": 14,
  402 + "fields": {
  403 + "module_name": "Observation Manager",
  404 + "version": "0.1.3",
  405 + "created": "2016-07-20 13:44:29",
  406 + "updated": "2016-07-20 13:44:29"
  407 + }
  408 +},
  409 +{
  410 + "model": "common.version",
  411 + "pk": 15,
  412 + "fields": {
  413 + "module_name": "Routine Manager",
  414 + "version": "0.1.2",
  415 + "created": "2016-07-20 13:44:29",
  416 + "updated": "2016-07-20 13:44:29"
  417 + }
  418 +},
  419 +{
  420 + "model": "common.version",
  421 + "pk": 16,
  422 + "fields": {
  423 + "module_name": "Monitoring",
  424 + "version": "0.1.3",
  425 + "created": "2016-07-20 13:44:29",
  426 + "updated": "2016-07-20 13:44:29"
  427 + }
  428 +},
  429 +{
  430 + "model": "common.version",
  431 + "pk": 17,
  432 + "fields": {
  433 + "module_name": "Scheduler",
  434 + "version": "0.1.2",
  435 + "created": "2016-07-20 13:44:29",
  436 + "updated": "2016-07-20 13:44:29"
  437 + }
  438 +},
  439 +{
  440 + "model": "common.version",
  441 + "pk": 18,
  442 + "fields": {
  443 + "module_name": "User Manager",
  444 + "version": "0.1.1",
  445 + "created": "2016-07-20 13:44:29",
  446 + "updated": "2016-07-20 13:44:29"
  447 + }
  448 +},
  449 +{
  450 + "model": "common.version",
  451 + "pk": 19,
  452 + "fields": {
  453 + "module_name": "Analyzer",
  454 + "version": "0.1.2",
  455 + "created": "2016-07-20 13:44:29",
  456 + "updated": "2016-07-20 13:44:29"
  457 + }
  458 +},
  459 +{
  460 + "model": "common.pyrosuser",
  461 + "pk": 5,
  462 + "fields": {
  463 + "password": "pbkdf2_sha256$24000$HRial3QUfrlz$bVuEzQaXthOd9GZVXd2449LDEF8EMQure69nA/Hu7qQ=",
  464 + "last_login": "2016-08-10 15:16:42.327",
  465 + "is_superuser": true,
  466 + "username": "pyros",
  467 + "first_name": "",
  468 + "last_name": "",
  469 + "email": "admin@example.com",
  470 + "is_staff": true,
  471 + "is_active": true,
  472 + "date_joined": "2016-08-10 15:15:58.481",
  473 + "groups": [],
  474 + "user_permissions": [],
  475 + "country": 1,
  476 + "user_level": 1,
  477 + "desc": "",
  478 + "created": "2016-08-11 07:54:05.627",
  479 + "updated": "2016-08-11 07:54:05.627",
  480 + "tel": "",
  481 + "address": "",
  482 + "laboratory": "IRAP",
  483 + "last_connect": null,
  484 + "cur_connect": null,
  485 + "putvalid_beg": null,
  486 + "putvalid_end": null,
  487 + "acqvalid_beg": "",
  488 + "acqvalid_end": "",
  489 + "quota": 1000.0,
  490 + "quota_rea": null,
  491 + "u_priority": 1,
  492 + "p_priority": 1,
  493 + "dir_level": null,
  494 + "can_del_void_req": false
  495 + }
  496 +}
  497 +]
src/misc/fixtures/make_current_is_TZ.sh 0 → 100755
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +
  2 +function make_change() {
  3 + for f in *_TZ.json ; do fname=$(basename $f _TZ.json) ; newname=${fname}.json ; echo "cp $f to $newname"; cp -p $f $newname ; done
  4 +}
  5 +
  6 +
  7 +
  8 +make_change
  9 +cd tests/
  10 +make_change
  11 +ls -l ../
  12 +ls -l
  13 +
src/misc/fixtures/make_current_is_noTZ.sh 0 → 100755
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +
  2 +function make_change() {
  3 + for f in *_noTZ.json ; do fname=$(basename $f _noTZ.json) ; newname=${fname}.json ; echo "cp $f to $newname"; cp -p $f $newname ; done
  4 +}
  5 +
  6 +
  7 +
  8 +make_change
  9 +cd tests/
  10 +make_change
  11 +ls -l ../
  12 +ls -l
  13 +
src/misc/fixtures/tests/alert_mgr_test_noTZ.json 0 → 100644
@@ -0,0 +1,311 @@ @@ -0,0 +1,311 @@
  1 +[
  2 +{
  3 + "model": "common.country",
  4 + "pk": 1,
  5 + "fields": {
  6 + "name": "France",
  7 + "desc": "",
  8 + "quota": null
  9 + }
  10 +},
  11 +{
  12 + "model": "common.detector",
  13 + "pk": 1,
  14 + "fields": {
  15 + "telescope": 1,
  16 + "nb_photo_x": null,
  17 + "nb_photo_y": null,
  18 + "photo_size_x": null,
  19 + "photo_size_y": null,
  20 + "has_shutter": false,
  21 + "equivalent_foc_len": "",
  22 + "acq_start": null,
  23 + "acq_stop": null,
  24 + "check_temp": null,
  25 + "gain": null,
  26 + "readout_noise": null,
  27 + "readout_time": null,
  28 + "idcam_readout_mode": null,
  29 + "name": "Cagire",
  30 + "desc": "",
  31 + "created": "2016-05-13 11:49:49.663",
  32 + "updated": "2016-05-13 11:49:49.664",
  33 + "is_online": false,
  34 + "status": "",
  35 + "maintenance_date": null
  36 + }
  37 +},
  38 +{
  39 + "model": "common.detector",
  40 + "pk": 2,
  41 + "fields": {
  42 + "telescope": 1,
  43 + "nb_photo_x": null,
  44 + "nb_photo_y": null,
  45 + "photo_size_x": null,
  46 + "photo_size_y": null,
  47 + "has_shutter": false,
  48 + "equivalent_foc_len": "",
  49 + "acq_start": null,
  50 + "acq_stop": null,
  51 + "check_temp": null,
  52 + "gain": null,
  53 + "readout_noise": null,
  54 + "readout_time": null,
  55 + "idcam_readout_mode": null,
  56 + "name": "Visible camera",
  57 + "desc": "",
  58 + "created": "2016-05-13 11:50:17.644",
  59 + "updated": "2016-05-13 11:50:17.644",
  60 + "is_online": false,
  61 + "status": "",
  62 + "maintenance_date": null
  63 + }
  64 +},
  65 +{
  66 + "model": "common.filterwheel",
  67 + "pk": 1,
  68 + "fields": {
  69 + "detector": 1,
  70 + "name": "Cagire FW",
  71 + "desc": "",
  72 + "created": "2016-06-28 13:28:28.298",
  73 + "updated": "2016-06-28 13:28:28.298",
  74 + "is_online": false,
  75 + "status": "",
  76 + "maintenance_date": null
  77 + }
  78 +},
  79 +{
  80 + "model": "common.filterwheel",
  81 + "pk": 2,
  82 + "fields": {
  83 + "detector": 2,
  84 + "name": "Visible Camera FW",
  85 + "desc": "",
  86 + "created": "2016-06-28 13:28:46.887",
  87 + "updated": "2016-06-28 13:28:46.887",
  88 + "is_online": false,
  89 + "status": "",
  90 + "maintenance_date": null
  91 + }
  92 +},
  93 +{
  94 + "model": "common.filter",
  95 + "pk": 1,
  96 + "fields": {
  97 + "filter_wheel": 1,
  98 + "category": "",
  99 + "transmission_curve_doc": "",
  100 + "name": "First infrared filter",
  101 + "desc": "",
  102 + "created": "2016-05-13 11:49:56.579",
  103 + "updated": "2016-05-13 11:49:56.579",
  104 + "is_online": false,
  105 + "status": "",
  106 + "maintenance_date": null
  107 + }
  108 +},
  109 +{
  110 + "model": "common.filter",
  111 + "pk": 2,
  112 + "fields": {
  113 + "filter_wheel": 1,
  114 + "category": "",
  115 + "transmission_curve_doc": "",
  116 + "name": "Second infrared filter",
  117 + "desc": "",
  118 + "created": "2016-05-13 11:50:07.592",
  119 + "updated": "2016-05-13 11:50:07.592",
  120 + "is_online": false,
  121 + "status": "",
  122 + "maintenance_date": null
  123 + }
  124 +},
  125 +{
  126 + "model": "common.filter",
  127 + "pk": 3,
  128 + "fields": {
  129 + "filter_wheel": 2,
  130 + "category": "",
  131 + "transmission_curve_doc": "",
  132 + "name": "First visible filter",
  133 + "desc": "",
  134 + "created": "2016-05-13 11:50:02.012",
  135 + "updated": "2016-05-13 11:50:02.013",
  136 + "is_online": false,
  137 + "status": "",
  138 + "maintenance_date": null
  139 + }
  140 +},
  141 +{
  142 + "model": "common.filter",
  143 + "pk": 4,
  144 + "fields": {
  145 + "filter_wheel": 2,
  146 + "category": "",
  147 + "transmission_curve_doc": "",
  148 + "name": "Second visible filter",
  149 + "desc": "",
  150 + "created": "2016-05-13 11:50:11.226",
  151 + "updated": "2016-05-13 11:50:11.226",
  152 + "is_online": false,
  153 + "status": "",
  154 + "maintenance_date": null
  155 + }
  156 +},
  157 +{
  158 + "model": "common.scientificprogram",
  159 + "pk": 1,
  160 + "fields": {
  161 + "name": "GRB",
  162 + "desc": "",
  163 + "quota": 9999.0,
  164 + "priority": 0,
  165 + "pyros_users": [
  166 + 1
  167 + ]
  168 + }
  169 +},
  170 +{
  171 + "model": "common.strategyobs",
  172 + "pk": 1,
  173 + "fields": {
  174 + "name": "strat1",
  175 + "desc": "",
  176 + "xml_file": "strat1.xml"
  177 + }
  178 +},
  179 +{
  180 + "model": "common.strategyobs",
  181 + "pk": 2,
  182 + "fields": {
  183 + "name": "strat2",
  184 + "desc": "",
  185 + "xml_file": "strat2.xml"
  186 + }
  187 +},
  188 +{
  189 + "model": "common.telescope",
  190 + "pk": 1,
  191 + "fields": {
  192 + "mount_type": "",
  193 + "diameter": null,
  194 + "status": "",
  195 + "latitude": null,
  196 + "longitude": null,
  197 + "sens": "",
  198 + "altitude": null,
  199 + "readout_time": null,
  200 + "slew_time": null,
  201 + "slew_dead": null,
  202 + "slew_rate_max": null,
  203 + "horizon_type": "",
  204 + "horizon_def": null,
  205 + "lim_dec_max": null,
  206 + "lim_dec_min": null,
  207 + "lim_ha_rise": null,
  208 + "lim_ha_set": null,
  209 + "address": "",
  210 + "night_elev_sun": null,
  211 + "mpc_code": "",
  212 + "name": "Telescope",
  213 + "desc": "",
  214 + "created": "2016-05-13 11:50:14.326",
  215 + "updated": "2016-05-13 11:50:14.326",
  216 + "is_online": false,
  217 + "maintenance_date": null
  218 + }
  219 +},
  220 +{
  221 + "model": "common.userlevel",
  222 + "pk": 1,
  223 + "fields": {
  224 + "name": "Developer",
  225 + "desc": "",
  226 + "priority": 0,
  227 + "quota": 9999.0
  228 + }
  229 +},
  230 +{
  231 + "model": "common.pyrosuser",
  232 + "pk": 3,
  233 + "fields": {
  234 + "country": 1,
  235 + "user_level": 1,
  236 + "desc": null,
  237 + "created": "2016-06-21 13:07:19.911",
  238 + "updated": "2016-06-21 13:07:19.911",
  239 + "tel": "test",
  240 + "address": "test",
  241 + "laboratory": "test",
  242 + "last_connect": null,
  243 + "cur_connect": null,
  244 + "putvalid_beg": null,
  245 + "putvalid_end": null,
  246 + "acqvalid_beg": null,
  247 + "acqvalid_end": null,
  248 + "quota": 100,
  249 + "quota_rea": null,
  250 + "u_priority": null,
  251 + "p_priority": null,
  252 + "dir_level": null,
  253 + "can_del_void_req": false,
  254 + "password": "pbkdf2_sha256$24000$bKJO902RCk0w$zxUz9uiSYG85ymuvl5rNLLqT/LZwrLwpVj5WfwwSyKE=",
  255 + "last_login": "2016-06-21 13:07:34.383",
  256 + "is_superuser": false,
  257 + "username": "test@test.test",
  258 + "first_name": "test",
  259 + "last_name": "test",
  260 + "email": "test@test.test",
  261 + "is_staff": false,
  262 + "is_active": true,
  263 + "date_joined": "2016-06-21 13:07:19.609",
  264 + "groups": [],
  265 + "user_permissions": []
  266 + }
  267 +},
  268 +
  269 +{
  270 + "model": "common.alert",
  271 + "pk": 8,
  272 + "fields": {
  273 + "request": 65,
  274 + "strategyobs": 1,
  275 + "voevent_file": null,
  276 + "author": null,
  277 + "burst_jd": null,
  278 + "burst_ra": null,
  279 + "burst_dec": null,
  280 + "astro_coord_system": null,
  281 + "jd_send": null,
  282 + "jd_received": null,
  283 + "trig_id": 5,
  284 + "error_radius": null,
  285 + "defly_not_grb": false,
  286 + "editor": null
  287 + }
  288 +},
  289 +
  290 +
  291 +{
  292 + "model": "common.request",
  293 + "pk": 65,
  294 + "fields": {
  295 + "pyros_user": 3,
  296 + "scientific_program": 1,
  297 + "name": "Simulation_request",
  298 + "desc": null,
  299 + "created": "2016-06-21 12:51:24.293",
  300 + "updated": "2016-06-21 12:51:24.293",
  301 + "is_alert": true,
  302 + "target_type": null,
  303 + "status": null,
  304 + "autodeposit": false,
  305 + "checkpoint": null,
  306 + "flag": null,
  307 + "complete": true,
  308 + "submitted": true
  309 + }
  310 +}
  311 +]
src/misc/fixtures/tests/common_test_noTZ.json 0 → 100644
@@ -0,0 +1,268 @@ @@ -0,0 +1,268 @@
  1 +[
  2 +{
  3 + "model": "common.country",
  4 + "pk": 1,
  5 + "fields": {
  6 + "name": "France",
  7 + "desc": "",
  8 + "quota": null
  9 + }
  10 +},
  11 +{
  12 + "model": "common.detector",
  13 + "pk": 1,
  14 + "fields": {
  15 + "telescope": 1,
  16 + "status": "",
  17 + "nb_photo_x": null,
  18 + "nb_photo_y": null,
  19 + "photo_size_x": null,
  20 + "photo_size_y": null,
  21 + "has_shutter": false,
  22 + "equivalent_foc_len": "",
  23 + "acq_start": null,
  24 + "acq_stop": null,
  25 + "check_temp": null,
  26 + "gain": null,
  27 + "readout_noise": null,
  28 + "readout_time": null,
  29 + "idcam_readout_mode": null,
  30 + "name": "Cagire",
  31 + "desc": "",
  32 + "created": "2016-05-13 11:49:49.663",
  33 + "updated": "2016-05-13 11:49:49.664",
  34 + "is_online": false,
  35 + "maintenance_date": null
  36 + }
  37 +},
  38 +{
  39 + "model": "common.detector",
  40 + "pk": 2,
  41 + "fields": {
  42 + "telescope": 1,
  43 + "nb_photo_x": null,
  44 + "nb_photo_y": null,
  45 + "photo_size_x": null,
  46 + "photo_size_y": null,
  47 + "has_shutter": false,
  48 + "equivalent_foc_len": "",
  49 + "acq_start": null,
  50 + "acq_stop": null,
  51 + "check_temp": null,
  52 + "gain": null,
  53 + "readout_noise": null,
  54 + "readout_time": null,
  55 + "idcam_readout_mode": null,
  56 + "name": "Visible camera",
  57 + "desc": "",
  58 + "created": "2016-05-13 11:50:17.644",
  59 + "updated": "2016-05-13 11:50:17.644",
  60 + "is_online": false,
  61 + "status": "",
  62 + "maintenance_date": null
  63 + }
  64 +},
  65 +{
  66 + "model": "common.filterwheel",
  67 + "pk": 1,
  68 + "fields": {
  69 + "name": "Cagire FW",
  70 + "desc": "",
  71 + "created": "2016-06-28 13:28:28.298",
  72 + "updated": "2016-06-28 13:28:28.298",
  73 + "is_online": false,
  74 + "status": "",
  75 + "maintenance_date": null,
  76 + "detector": 1
  77 + }
  78 +},
  79 +{
  80 + "model": "common.filterwheel",
  81 + "pk": 2,
  82 + "fields": {
  83 + "detector": 2,
  84 + "name": "Visible Camera FW",
  85 + "desc": "",
  86 + "created": "2016-06-28 13:28:46.887",
  87 + "updated": "2016-06-28 13:28:46.887",
  88 + "is_online": false,
  89 + "status": "",
  90 + "maintenance_date": null
  91 + }
  92 +},
  93 +{
  94 + "model": "common.filter",
  95 + "pk": 1,
  96 + "fields": {
  97 + "filter_wheel": 1,
  98 + "category": "",
  99 + "transmission_curve_doc": "",
  100 + "name": "First infrared filter",
  101 + "desc": "",
  102 + "created": "2016-05-13 11:49:56.579",
  103 + "updated": "2016-05-13 11:49:56.579",
  104 + "is_online": false,
  105 + "status": "",
  106 + "maintenance_date": null
  107 + }
  108 +},
  109 +{
  110 + "model": "common.filter",
  111 + "pk": 2,
  112 + "fields": {
  113 + "filter_wheel": 1,
  114 + "category": "",
  115 + "transmission_curve_doc": "",
  116 + "name": "Second infrared filter",
  117 + "desc": "",
  118 + "created": "2016-05-13 11:50:07.592",
  119 + "updated": "2016-05-13 11:50:07.592",
  120 + "is_online": false,
  121 + "status": "",
  122 + "maintenance_date": null
  123 + }
  124 +},
  125 +{
  126 + "model": "common.filter",
  127 + "pk": 3,
  128 + "fields": {
  129 + "filter_wheel": 2,
  130 + "category": "",
  131 + "transmission_curve_doc": "",
  132 + "name": "First visible filter",
  133 + "desc": "",
  134 + "created": "2016-05-13 11:50:02.012",
  135 + "updated": "2016-05-13 11:50:02.013",
  136 + "is_online": false,
  137 + "status": "",
  138 + "maintenance_date": null
  139 + }
  140 +},
  141 +{
  142 + "model": "common.filter",
  143 + "pk": 4,
  144 + "fields": {
  145 + "filter_wheel": 2,
  146 + "category": "",
  147 + "transmission_curve_doc": "",
  148 + "name": "Second visible filter",
  149 + "desc": "",
  150 + "created": "2016-05-13 11:50:11.226",
  151 + "updated": "2016-05-13 11:50:11.226",
  152 + "is_online": false,
  153 + "status": "",
  154 + "maintenance_date": null
  155 + }
  156 +},
  157 +{
  158 + "model": "common.scientificprogram",
  159 + "pk": 1,
  160 + "fields": {
  161 + "name": "GRB",
  162 + "desc": "",
  163 + "quota": 9999.0,
  164 + "priority": 0,
  165 + "pyros_users": [
  166 + 1
  167 + ]
  168 + }
  169 +},
  170 +{
  171 + "model": "common.strategyobs",
  172 + "pk": 1,
  173 + "fields": {
  174 + "name": "strat1",
  175 + "desc": "",
  176 + "xml_file": "strat1.xml"
  177 + }
  178 +},
  179 +{
  180 + "model": "common.strategyobs",
  181 + "pk": 2,
  182 + "fields": {
  183 + "name": "strat2",
  184 + "desc": "",
  185 + "xml_file": "strat2.xml"
  186 + }
  187 +},
  188 +{
  189 + "model": "common.telescope",
  190 + "pk": 1,
  191 + "fields": {
  192 + "mount_type": "",
  193 + "diameter": null,
  194 + "status": "",
  195 + "latitude": null,
  196 + "longitude": null,
  197 + "sens": "",
  198 + "altitude": null,
  199 + "readout_time": null,
  200 + "slew_time": null,
  201 + "slew_dead": null,
  202 + "slew_rate_max": null,
  203 + "horizon_type": "",
  204 + "horizon_def": null,
  205 + "lim_dec_max": null,
  206 + "lim_dec_min": null,
  207 + "lim_ha_rise": null,
  208 + "lim_ha_set": null,
  209 + "address": "",
  210 + "night_elev_sun": null,
  211 + "mpc_code": "",
  212 + "name": "Telescope",
  213 + "desc": "",
  214 + "created": "2016-05-13 11:50:14.326",
  215 + "updated": "2016-05-13 11:50:14.326",
  216 + "is_online": false,
  217 + "maintenance_date": null
  218 + }
  219 +},
  220 +{
  221 + "model": "common.userlevel",
  222 + "pk": 1,
  223 + "fields": {
  224 + "name": "Developer",
  225 + "desc": "",
  226 + "priority": 0,
  227 + "quota": 9999.0
  228 + }
  229 +},
  230 +{
  231 + "model": "common.pyrosuser",
  232 + "pk": 1,
  233 + "fields": {
  234 + "password": "pbkdf2_sha256$24000$NC9UO4LPGvDN$+pkRcZUbmV3HEtbrhBdDCSPnAsDVValrbwLt7cXqrJE=",
  235 + "last_login": "2016-06-03 09:27:53.245",
  236 + "is_superuser": true,
  237 + "username": "haribo",
  238 + "first_name": "",
  239 + "last_name": "",
  240 + "email": "",
  241 + "is_staff": true,
  242 + "is_active": true,
  243 + "date_joined": "2016-05-02 14:02:36.495",
  244 + "groups": [],
  245 + "user_permissions": [],
  246 + "country": 1,
  247 + "user_level": 1,
  248 + "desc": "",
  249 + "created": "2016-06-03 09:29:15.450",
  250 + "updated": "2016-06-03 09:29:15.450",
  251 + "tel": "",
  252 + "address": "",
  253 + "laboratory": "",
  254 + "last_connect": null,
  255 + "cur_connect": null,
  256 + "putvalid_beg": null,
  257 + "putvalid_end": null,
  258 + "acqvalid_beg": "",
  259 + "acqvalid_end": "",
  260 + "quota": 9999.0,
  261 + "quota_rea": 9999.0,
  262 + "u_priority": null,
  263 + "p_priority": null,
  264 + "dir_level": null,
  265 + "can_del_void_req": false
  266 + }
  267 +}
  268 +]
src/misc/fixtures/tests/routine_mgr_test_noTZ.json 0 → 100644
@@ -0,0 +1,349 @@ @@ -0,0 +1,349 @@
  1 +[
  2 +{
  3 + "model": "common.country",
  4 + "pk": 1,
  5 + "fields": {
  6 + "name": "France",
  7 + "desc": "",
  8 + "quota": null
  9 + }
  10 +},
  11 +{
  12 + "model": "common.detector",
  13 + "pk": 1,
  14 + "fields": {
  15 + "name": "Cagire",
  16 + "desc": "",
  17 + "created": "2016-05-13 11:49:49.663",
  18 + "updated": "2016-05-13 11:49:49.664",
  19 + "is_online": false,
  20 + "maintenance_date": null,
  21 + "telescope": 1,
  22 + "status": "",
  23 + "nb_photo_x": null,
  24 + "nb_photo_y": null,
  25 + "photo_size_x": null,
  26 + "photo_size_y": null,
  27 + "has_shutter": false,
  28 + "equivalent_foc_len": "",
  29 + "acq_start": null,
  30 + "acq_stop": null,
  31 + "check_temp": null,
  32 + "gain": null,
  33 + "readout_noise": null,
  34 + "readout_time": null,
  35 + "idcam_readout_mode": null
  36 + }
  37 +},
  38 +{
  39 + "model": "common.detector",
  40 + "pk": 2,
  41 + "fields": {
  42 + "name": "Visible camera",
  43 + "desc": "",
  44 + "created": "2016-05-13 11:50:17.644",
  45 + "updated": "2016-05-13 11:50:17.644",
  46 + "is_online": false,
  47 + "maintenance_date": null,
  48 + "telescope": 1,
  49 + "status": "",
  50 + "nb_photo_x": null,
  51 + "nb_photo_y": null,
  52 + "photo_size_x": null,
  53 + "photo_size_y": null,
  54 + "has_shutter": false,
  55 + "equivalent_foc_len": "",
  56 + "acq_start": null,
  57 + "acq_stop": null,
  58 + "check_temp": null,
  59 + "gain": null,
  60 + "readout_noise": null,
  61 + "readout_time": null,
  62 + "idcam_readout_mode": null
  63 + }
  64 +},
  65 +{
  66 + "model": "common.filterwheel",
  67 + "pk": 1,
  68 + "fields": {
  69 + "name": "Cagire FW",
  70 + "desc": "",
  71 + "created": "2016-06-28 13:28:28.298",
  72 + "updated": "2016-06-28 13:28:28.298",
  73 + "is_online": false,
  74 + "status": "",
  75 + "maintenance_date": null,
  76 + "detector": 1
  77 + }
  78 +},
  79 +{
  80 + "model": "common.filterwheel",
  81 + "pk": 2,
  82 + "fields": {
  83 + "name": "Visible Camera FW",
  84 + "desc": "",
  85 + "created": "2016-06-28 13:28:46.887",
  86 + "updated": "2016-06-28 13:28:46.887",
  87 + "is_online": false,
  88 + "status": "",
  89 + "maintenance_date": null,
  90 + "detector": 2
  91 + }
  92 +},
  93 +{
  94 + "model": "common.filter",
  95 + "pk": 1,
  96 + "fields": {
  97 + "name": "First infrared filter",
  98 + "desc": "",
  99 + "created": "2016-05-13 11:49:56.579",
  100 + "updated": "2016-05-13 11:49:56.579",
  101 + "is_online": false,
  102 + "status": "",
  103 + "maintenance_date": null,
  104 + "filter_wheel": 1,
  105 + "category": "",
  106 + "transmission_curve_doc": ""
  107 + }
  108 +},
  109 +{
  110 + "model": "common.filter",
  111 + "pk": 2,
  112 + "fields": {
  113 + "filter_wheel": 1,
  114 + "category": "",
  115 + "transmission_curve_doc": "",
  116 + "name": "Second infrared filter",
  117 + "desc": "",
  118 + "created": "2016-05-13 11:50:07.592",
  119 + "updated": "2016-05-13 11:50:07.592",
  120 + "is_online": false,
  121 + "status": "",
  122 + "maintenance_date": null
  123 + }
  124 +},
  125 +{
  126 + "model": "common.filter",
  127 + "pk": 3,
  128 + "fields": {
  129 + "filter_wheel": 2,
  130 + "category": "",
  131 + "transmission_curve_doc": "",
  132 + "name": "First visible filter",
  133 + "desc": "",
  134 + "created": "2016-05-13 11:50:02.012",
  135 + "updated": "2016-05-13 11:50:02.013",
  136 + "is_online": false,
  137 + "status": "",
  138 + "maintenance_date": null
  139 + }
  140 +},
  141 +{
  142 + "model": "common.filter",
  143 + "pk": 4,
  144 + "fields": {
  145 + "filter_wheel": 2,
  146 + "category": "",
  147 + "transmission_curve_doc": "",
  148 + "name": "Second visible filter",
  149 + "desc": "",
  150 + "created": "2016-05-13 11:50:11.226",
  151 + "updated": "2016-05-13 11:50:11.226",
  152 + "is_online": false,
  153 + "status": "",
  154 + "maintenance_date": null
  155 + }
  156 +},
  157 +{
  158 + "model": "common.scientificprogram",
  159 + "pk": 1,
  160 + "fields": {
  161 + "name": "GRB",
  162 + "desc": "",
  163 + "quota": 9999.0,
  164 + "priority": 0,
  165 + "pyros_users": [
  166 + 1
  167 + ]
  168 + }
  169 +},
  170 +{
  171 + "model": "common.strategyobs",
  172 + "pk": 1,
  173 + "fields": {
  174 + "name": "strat1",
  175 + "desc": "",
  176 + "xml_file": "strat1.xml"
  177 + }
  178 +},
  179 +{
  180 + "model": "common.strategyobs",
  181 + "pk": 2,
  182 + "fields": {
  183 + "name": "strat2",
  184 + "desc": "",
  185 + "xml_file": "strat2.xml"
  186 + }
  187 +},
  188 +{
  189 + "model": "common.telescope",
  190 + "pk": 1,
  191 + "fields": {
  192 + "name": "Telescope",
  193 + "desc": "",
  194 + "created": "2016-05-13 11:50:14.326",
  195 + "updated": "2016-05-13 11:50:14.326",
  196 + "is_online": false,
  197 + "maintenance_date": null,
  198 + "mount_type": "",
  199 + "diameter": null,
  200 + "status": "",
  201 + "latitude": null,
  202 + "longitude": null,
  203 + "sens": "",
  204 + "altitude": null,
  205 + "readout_time": null,
  206 + "slew_time": null,
  207 + "slew_dead": null,
  208 + "slew_rate_max": null,
  209 + "horizon_type": "",
  210 + "horizon_def": null,
  211 + "lim_dec_max": null,
  212 + "lim_dec_min": null,
  213 + "lim_ha_rise": null,
  214 + "lim_ha_set": null,
  215 + "address": "",
  216 + "night_elev_sun": null,
  217 + "mpc_code": ""
  218 + }
  219 +},
  220 +{
  221 + "model": "common.userlevel",
  222 + "pk": 1,
  223 + "fields": {
  224 + "name": "Developer",
  225 + "desc": "",
  226 + "priority": 0,
  227 + "quota": 9999.0
  228 + }
  229 +},
  230 +{
  231 + "model": "common.pyrosuser",
  232 + "pk": 3,
  233 + "fields": {
  234 + "password": "pbkdf2_sha256$24000$bKJO902RCk0w$zxUz9uiSYG85ymuvl5rNLLqT/LZwrLwpVj5WfwwSyKE=",
  235 + "last_login": "2016-06-21 13:07:34.383",
  236 + "is_superuser": false,
  237 + "username": "test@test.test",
  238 + "first_name": "test",
  239 + "last_name": "test",
  240 + "email": "test@test.test",
  241 + "is_staff": false,
  242 + "is_active": true,
  243 + "date_joined": "2016-06-21 13:07:19.609",
  244 + "groups": [],
  245 + "user_permissions": [],
  246 + "country": 1,
  247 + "user_level": 1,
  248 + "desc": null,
  249 + "created": "2016-06-21 13:07:19.911",
  250 + "updated": "2016-06-21 13:07:19.911",
  251 + "tel": "test",
  252 + "address": "test",
  253 + "laboratory": "test",
  254 + "last_connect": null,
  255 + "cur_connect": null,
  256 + "putvalid_beg": null,
  257 + "putvalid_end": null,
  258 + "acqvalid_beg": null,
  259 + "acqvalid_end": null,
  260 + "quota": null,
  261 + "quota_rea": null,
  262 + "u_priority": null,
  263 + "p_priority": null,
  264 + "dir_level": null,
  265 + "can_del_void_req": false
  266 + }
  267 +},{
  268 + "model": "common.request",
  269 + "pk": 66,
  270 + "fields": {
  271 + "pyros_user": 3,
  272 + "scientific_program": 1,
  273 + "name": "Simulation_request_strat2",
  274 + "desc": null,
  275 + "created": "2016-06-21 13:42:04.493",
  276 + "updated": "2016-06-22 12:34:09.401",
  277 + "is_alert": true,
  278 + "target_type": "dqsd",
  279 + "status": null,
  280 + "autodeposit": false,
  281 + "checkpoint": null,
  282 + "flag": null,
  283 + "complete": true,
  284 + "submitted": false
  285 + }
  286 +},
  287 +{
  288 + "model": "common.sequence",
  289 + "pk": 53,
  290 + "fields": {
  291 + "request": 66,
  292 + "name": "Simulation_request_strat2_0",
  293 + "desc": null,
  294 + "created": "2016-06-21 13:42:04.587",
  295 + "updated": "2016-06-22 12:32:16.892",
  296 + "is_alert": false,
  297 + "status": "CPL",
  298 + "target_coords": "sdfghj",
  299 + "with_drift": false,
  300 + "priority": 0,
  301 + "analysis_method": null,
  302 + "moon_min": null,
  303 + "alt_min": null,
  304 + "type": null,
  305 + "img_current": null,
  306 + "img_total": null,
  307 + "not_obs": false,
  308 + "obsolete": false,
  309 + "processing": false,
  310 + "flag": null,
  311 + "jd1": "0E-8",
  312 + "jd2": "9000000.00000000",
  313 + "t_prefered": "-1.00000000",
  314 + "duration": "0.00023148",
  315 + "overhead": "0E-8"
  316 + }
  317 +},
  318 +{
  319 + "model": "common.album",
  320 + "pk": 55,
  321 + "fields": {
  322 + "sequence": 53,
  323 + "detector": 2,
  324 + "name": "Simulation_request_strat2_01",
  325 + "desc": null,
  326 + "created": "2016-06-21 13:42:04.874",
  327 + "updated": "2016-06-22 12:32:16.787",
  328 + "complete": true
  329 + }
  330 +},
  331 +{
  332 + "model": "common.plan",
  333 + "pk": 58,
  334 + "fields": {
  335 + "album": 55,
  336 + "filter": 3,
  337 + "name": "Simulation_request_strat2_010",
  338 + "desc": null,
  339 + "created": "2016-06-21 13:42:05.309",
  340 + "updated": "2016-06-22 12:32:16.690",
  341 + "duration": 0.0002314814814814815,
  342 + "position": null,
  343 + "exposure_time": null,
  344 + "nb_images": 1,
  345 + "dithering": false,
  346 + "complete": true
  347 + }
  348 +}
  349 +]
src/pyros/settings.py
@@ -206,7 +206,7 @@ USE_L10N = True @@ -206,7 +206,7 @@ USE_L10N = True
206 # TODO: fix this 206 # TODO: fix this
207 # Necessary for ENV monitoring : 207 # Necessary for ENV monitoring :
208 USE_TZ = False 208 USE_TZ = False
209 -# Still necessary for "pyros.py simulator" (because of some fixtures that still use timezone-aware datetimes) 209 +#USE_TZ = True
210 #if USE_CELERY: USE_TZ = True 210 #if USE_CELERY: USE_TZ = True
211 211
212 # To find the media files {{ MEDIA_URL }} 212 # To find the media files {{ MEDIA_URL }}
src/pyros/test_settings.py renamed to src/pyros/test_settings_NOTUSED.py
1 -""" OBSOLETE FILE """  
2 -"""  
3 -Django settings for pyros project.  
4 -  
5 -Generated by 'django-admin startproject' using Django 1.9.4.  
6 -  
7 -For more information on this file, see  
8 -https://docs.djangoproject.com/en/1.9/topics/settings/  
9 -  
10 -For the full list of settings and their values, see  
11 -https://docs.djangoproject.com/en/1.9/ref/settings/  
12 -"""  
13 -  
14 -# Dictionary containing all the versions for the different modules  
15 -# IMPORTANT : I must be updated at every commit !  
16 -  
17 -MODULES_VERSIONS = {  
18 - "Alert Manager" : "0.2.4",  
19 - "Analyzer" : "0.1.2",  
20 - "Dashboard" : "0.1.1",  
21 - "Majordome" : "0.1.4",  
22 - "Monitoring" : "0.1.3",  
23 - "Observation Manager" : "0.1.3",  
24 - "Routine Manager" : "0.1.2",  
25 - "Scheduler" : "0.1.2",  
26 - "User Manager" : "0.1.1",  
27 - "Device" : "0.1.1"  
28 -}  
29 -  
30 -# Set MYSQL to False if you want to use SQLITE  
31 -# This line MUST NOT be changed at all except from changing True/False  
32 -# (or install_requirements script will become invalid)  
33 -MYSQL = True  
34 -  
35 -# YOU MUST CHANGE THIS VALUE IN PYROSRUN.SH TOO  
36 -TEST_PORT = 8001  
37 -# YOU MUST CHANGE THIS VALUE IN PYROSRUN.SH TOO  
38 -  
39 -  
40 -import os  
41 -  
42 -# Build paths inside the project like this: os.path.join(BASE_DIR, ...)  
43 -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))  
44 -  
45 -  
46 -# Quick-start development settings - unsuitable for production  
47 -# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/  
48 -  
49 -# SECURITY WARNING: keep the secret key used in production secret!  
50 -SECRET_KEY = '0*@w)$rq4x1c2w!c#gn58*$*u$w=s8uw2zpr_c3nj*u%qlxc23'  
51 -  
52 -# SECURITY WARNING: don't run with debug turned on in production!  
53 -DEBUG = True  
54 -  
55 -ALLOWED_HOSTS = ['localhost']  
56 -  
57 -  
58 -# Application definition  
59 -  
60 -INSTALLED_APPS = [  
61 - 'django.contrib.admin',  
62 - 'django.contrib.auth',  
63 - 'django.contrib.contenttypes',  
64 - 'django.contrib.sessions',  
65 - 'django.contrib.messages',  
66 - 'django.contrib.staticfiles',  
67 -  
68 - # for using "./manage.py graph_models" with graphviz:  
69 - # (https://projects.irap.omp.eu/projects/pyros/wiki/Project_Development#django-extensions-and-graphviz-useful-for-generating-an-image-of-all-the-models-and-their-relationships)  
70 - 'django_extensions',  
71 - 'test_without_migrations',  
72 - 'bootstrap3',  
73 - 'dashboard',  
74 - 'scheduler',  
75 - 'common',  
76 - 'alert_manager',  
77 - 'analyzer',  
78 - 'majordome',  
79 - 'monitoring',  
80 - 'observation_manager',  
81 - 'routine_manager',  
82 - 'user_manager',  
83 - 'devices'  
84 -]  
85 -  
86 -MIDDLEWARE_CLASSES = [  
87 - 'django.middleware.security.SecurityMiddleware',  
88 - 'django.contrib.sessions.middleware.SessionMiddleware',  
89 - 'django.middleware.common.CommonMiddleware',  
90 - 'django.middleware.csrf.CsrfViewMiddleware',  
91 - 'django.contrib.auth.middleware.AuthenticationMiddleware',  
92 - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',  
93 - 'django.contrib.messages.middleware.MessageMiddleware',  
94 - 'django.middleware.clickjacking.XFrameOptionsMiddleware',  
95 -]  
96 -  
97 -ROOT_URLCONF = 'pyros.urls'  
98 -  
99 -TEMPLATES = [  
100 - {  
101 - 'BACKEND': 'django.template.backends.django.DjangoTemplates',  
102 - 'DIRS': ['misc/templates'],  
103 - 'APP_DIRS': True,  
104 - 'OPTIONS': {  
105 - 'context_processors': [  
106 - 'django.template.context_processors.debug',  
107 - 'django.template.context_processors.request',  
108 - 'django.contrib.auth.context_processors.auth',  
109 - 'django.contrib.messages.context_processors.messages',  
110 - ],  
111 - },  
112 - },  
113 -]  
114 -  
115 -WSGI_APPLICATION = 'pyros.wsgi.application'  
116 -  
117 -FIXTURE_DIRS = (  
118 - 'misc/fixtures/',  
119 -)  
120 -  
121 -LOGIN_URL = "/"  
122 -  
123 -# Database  
124 -# https://docs.djangoproject.com/en/1.9/ref/settings/#databases  
125 -  
126 -# EP modif  
127 -  
128 -CELERY_TEST = False  
129 -  
130 -if not CELERY_TEST:  
131 - if not MYSQL:  
132 - DATABASES = {  
133 - 'default': {  
134 - 'ENGINE': 'django.db.backends.sqlite3',  
135 - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),  
136 - }  
137 - }  
138 - else:  
139 - DATABASES = {  
140 - 'default': {  
141 - 'ENGINE': 'django.db.backends.mysql',  
142 - 'NAME': 'test_pyros',  
143 - 'USER': 'pyros',  
144 - 'PASSWORD': 'DjangoPyros',  
145 - }  
146 - }  
147 -else:  
148 - DATABASES = {  
149 - 'default': {  
150 - 'ENGINE': 'django.db.backends.sqlite3',  
151 - 'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'),  
152 - 'TEST': {  
153 - 'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'),  
154 - },  
155 - }  
156 - }  
157 -  
158 -  
159 -# Password validation  
160 -# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators  
161 -  
162 -AUTH_PASSWORD_VALIDATORS = [  
163 - {  
164 - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',  
165 - },  
166 - {  
167 - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',  
168 - },  
169 - {  
170 - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',  
171 - },  
172 - {  
173 - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',  
174 - },  
175 -]  
176 -  
177 -  
178 -# Internationalization  
179 -# https://docs.djangoproject.com/en/1.9/topics/i18n/  
180 -  
181 -LANGUAGE_CODE = 'en-us'  
182 -  
183 -TIME_ZONE = 'UTC'  
184 -  
185 -USE_I18N = True  
186 -  
187 -USE_L10N = True  
188 -  
189 -USE_TZ = True  
190 -  
191 -  
192 -# To find the media files {{ MEDIA_URL }}  
193 -MEDIA_URL = '/public/static/media/'  
194 -  
195 -  
196 -# To find the static files in the app/static/ap/... folders  
197 -STATIC_URL = '/public/static/'  
198 -  
199 -# To find the static files in src/static/. Any local directory can be added to this list.  
200 -STATICFILES_DIRS = (  
201 - os.path.join(BASE_DIR, "misc", "static"),  
202 - )  
203 -  
204 -# Used for deployment (DEBUG = False). Need to run "python manage.py collectstatic" to fill it.  
205 -STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'public', 'static')  
206 -  
207 -  
208 -# EP added  
209 -if not DEBUG:  
210 - '''  
211 - CACHES = {  
212 - 'default': {  
213 - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',  
214 - 'LOCATION': '127.0.0.1:11211',  
215 - }  
216 - }  
217 - '''  
218 - CACHES = {  
219 - 'default': {  
220 - 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',  
221 - 'LOCATION': '/var/tmp/django_cache',  
222 - }  
223 - }  
224 -  
225 -else:  
226 - CACHES = {  
227 - 'default': {  
228 - 'BACKEND': 'django.core.cache.backends.dummy.DummyCache',  
229 - }  
230 - }  
231 -  
232 -# from django.core.cache import cache  
233 -# cache.clear()  
234 -  
235 -# CELERY CONFIG  
236 -  
237 -# CELERY_RESULT_BACKEND = 'rpc://'  
238 -CELERY_RESULT_BACKEND = 'amqp'  
239 -  
240 -CELERY_ACCEPT_CONTENT = ['json']  
241 -CELERY_TASK_SERIALIZER = 'json'  
242 -CELERY_RESULT_SERIALIZER = 'json'  
243 -  
244 -CELERY_IMPORTS = (  
245 - "alert_manager.tasks",  
246 - "analyzer.tasks",  
247 - "majordome.tasks",  
248 - "monitoring.tasks",  
249 - "observation_manager.tasks",  
250 - "scheduler.tasks",  
251 -)  
252 -  
253 -# This config allows only 1 process / queue. We replace it by the -c option at celery workers creation.  
254 -# CELERYD_CONCURRENCY = 1  
255 -  
256 -''' Following config is needed for manual purge '''  
257 -CELERY_ACKS_LATE = False  
258 -CELERYD_PREFETCH_MULTIPLIER = 1  
259 -  
260 -CELERY_QUEUES = {  
261 - "alert_listener_q": {"exchange": "alert_listener_q", "routing_key": "alert_listener_q"},  
262 - "analysis_q": {"exchange": "analysis_q", "routing_key": "analysis_q"},  
263 - "system_status_q": {"exchange": "system_status_q", "routing_key": "system_status_q"},  
264 - "change_obs_conditions_q": {"exchange": "change_obs_conditions_q", "routing_key": "change_obs_conditions_q"},  
265 - "monitoring_q": {"exchange": "monitoring_q", "routing_key": "monitoring_q"},  
266 - "scheduling_q": {"exchange": "scheduling_q", "routing_key": "scheduling_q"},  
267 - "execute_sequence_q": {"exchange": "execute_sequence_q", "routing_key": "execute_sequence_q"},  
268 - "execute_plan_vis_q": {"exchange": "execute_plan_vis_q", "routing_key": "execute_plan_vis_q"},  
269 - "execute_plan_nir_q": {"exchange": "execute_plan_nir_q", "routing_key": "execute_plan_nir_q"},  
270 - "create_calibrations_q": {"exchange": "create_calibrations_q", "routing_key": "create_calibrations_q"},  
271 -}  
272 -  
273 -CELERY_ROUTES = {  
274 - "alert_manager.tasks.alert_listener": {"queue": "alert_listener_q"},  
275 - "analyzer.tasks.analysis": {"queue": "analysis_q"},  
276 - "majordome.tasks.execute_sequence": {"queue": "execute_sequence_q"},  
277 - "majordome.tasks.system_pause": {"queue": "system_status_q"},  
278 - "majordome.tasks.system_restart": {"queue": "system_status_q"},  
279 - "majordome.tasks.change_obs_conditions": {"queue": "change_obs_conditions_q"},  
280 - "monitoring.tasks.monitoring": {"queue": "monitoring_q"},  
281 - "observation_manager.tasks.execute_plan_vis": {"queue": "execute_plan_vis_q"},  
282 - "observation_manager.tasks.execute_plan_nir": {"queue": "execute_plan_nir_q"},  
283 - "observation_manager.tasks.create_calibrations": {"queue": "create_calibrations_q"},  
284 - "scheduler.tasks.scheduling": {"queue": "scheduling_q"},  
285 -}  
286 -  
287 -''' Removes pickle warning '''  
288 -CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml'] 1 +""" OBSOLETE FILE """
  2 +"""
  3 +Django settings for pyros project.
  4 +
  5 +Generated by 'django-admin startproject' using Django 1.9.4.
  6 +
  7 +For more information on this file, see
  8 +https://docs.djangoproject.com/en/1.9/topics/settings/
  9 +
  10 +For the full list of settings and their values, see
  11 +https://docs.djangoproject.com/en/1.9/ref/settings/
  12 +"""
  13 +
  14 +# Dictionary containing all the versions for the different modules
  15 +# IMPORTANT : I must be updated at every commit !
  16 +
  17 +MODULES_VERSIONS = {
  18 + "Alert Manager" : "0.2.4",
  19 + "Analyzer" : "0.1.2",
  20 + "Dashboard" : "0.1.1",
  21 + "Majordome" : "0.1.4",
  22 + "Monitoring" : "0.1.3",
  23 + "Observation Manager" : "0.1.3",
  24 + "Routine Manager" : "0.1.2",
  25 + "Scheduler" : "0.1.2",
  26 + "User Manager" : "0.1.1",
  27 + "Device" : "0.1.1"
  28 +}
  29 +
  30 +# Set MYSQL to False if you want to use SQLITE
  31 +# This line MUST NOT be changed at all except from changing True/False
  32 +# (or install_requirements script will become invalid)
  33 +MYSQL = True
  34 +
  35 +# YOU MUST CHANGE THIS VALUE IN PYROSRUN.SH TOO
  36 +TEST_PORT = 8001
  37 +# YOU MUST CHANGE THIS VALUE IN PYROSRUN.SH TOO
  38 +
  39 +
  40 +import os
  41 +
  42 +# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  43 +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  44 +
  45 +
  46 +# Quick-start development settings - unsuitable for production
  47 +# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
  48 +
  49 +# SECURITY WARNING: keep the secret key used in production secret!
  50 +SECRET_KEY = '0*@w)$rq4x1c2w!c#gn58*$*u$w=s8uw2zpr_c3nj*u%qlxc23'
  51 +
  52 +# SECURITY WARNING: don't run with debug turned on in production!
  53 +DEBUG = True
  54 +
  55 +ALLOWED_HOSTS = ['localhost']
  56 +
  57 +
  58 +# Application definition
  59 +
  60 +INSTALLED_APPS = [
  61 + 'django.contrib.admin',
  62 + 'django.contrib.auth',
  63 + 'django.contrib.contenttypes',
  64 + 'django.contrib.sessions',
  65 + 'django.contrib.messages',
  66 + 'django.contrib.staticfiles',
  67 +
  68 + # for using "./manage.py graph_models" with graphviz:
  69 + # (https://projects.irap.omp.eu/projects/pyros/wiki/Project_Development#django-extensions-and-graphviz-useful-for-generating-an-image-of-all-the-models-and-their-relationships)
  70 + 'django_extensions',
  71 + 'test_without_migrations',
  72 + 'bootstrap3',
  73 + 'dashboard',
  74 + 'scheduler',
  75 + 'common',
  76 + 'alert_manager',
  77 + 'analyzer',
  78 + 'majordome',
  79 + 'monitoring',
  80 + 'observation_manager',
  81 + 'routine_manager',
  82 + 'user_manager',
  83 + 'devices'
  84 +]
  85 +
  86 +MIDDLEWARE_CLASSES = [
  87 + 'django.middleware.security.SecurityMiddleware',
  88 + 'django.contrib.sessions.middleware.SessionMiddleware',
  89 + 'django.middleware.common.CommonMiddleware',
  90 + 'django.middleware.csrf.CsrfViewMiddleware',
  91 + 'django.contrib.auth.middleware.AuthenticationMiddleware',
  92 + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  93 + 'django.contrib.messages.middleware.MessageMiddleware',
  94 + 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  95 +]
  96 +
  97 +ROOT_URLCONF = 'pyros.urls'
  98 +
  99 +TEMPLATES = [
  100 + {
  101 + 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  102 + 'DIRS': ['misc/templates'],
  103 + 'APP_DIRS': True,
  104 + 'OPTIONS': {
  105 + 'context_processors': [
  106 + 'django.template.context_processors.debug',
  107 + 'django.template.context_processors.request',
  108 + 'django.contrib.auth.context_processors.auth',
  109 + 'django.contrib.messages.context_processors.messages',
  110 + ],
  111 + },
  112 + },
  113 +]
  114 +
  115 +WSGI_APPLICATION = 'pyros.wsgi.application'
  116 +
  117 +FIXTURE_DIRS = (
  118 + 'misc/fixtures/',
  119 +)
  120 +
  121 +LOGIN_URL = "/"
  122 +
  123 +# Database
  124 +# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
  125 +
  126 +# EP modif
  127 +
  128 +CELERY_TEST = False
  129 +
  130 +if not CELERY_TEST:
  131 + if not MYSQL:
  132 + DATABASES = {
  133 + 'default': {
  134 + 'ENGINE': 'django.db.backends.sqlite3',
  135 + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  136 + }
  137 + }
  138 + else:
  139 + DATABASES = {
  140 + 'default': {
  141 + 'ENGINE': 'django.db.backends.mysql',
  142 + 'NAME': 'test_pyros',
  143 + 'USER': 'pyros',
  144 + 'PASSWORD': 'DjangoPyros',
  145 + }
  146 + }
  147 +else:
  148 + DATABASES = {
  149 + 'default': {
  150 + 'ENGINE': 'django.db.backends.sqlite3',
  151 + 'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'),
  152 + 'TEST': {
  153 + 'NAME': os.path.join(BASE_DIR, 'testdb.sqlite3'),
  154 + },
  155 + }
  156 + }
  157 +
  158 +
  159 +# Password validation
  160 +# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
  161 +
  162 +AUTH_PASSWORD_VALIDATORS = [
  163 + {
  164 + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  165 + },
  166 + {
  167 + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  168 + },
  169 + {
  170 + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  171 + },
  172 + {
  173 + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  174 + },
  175 +]
  176 +
  177 +
  178 +# Internationalization
  179 +# https://docs.djangoproject.com/en/1.9/topics/i18n/
  180 +
  181 +#LANGUAGE_CODE = 'en-us'
  182 +LANGUAGE_CODE = 'fr-FR'
  183 +
  184 +#TIME_ZONE = 'UTC'
  185 +TIME_ZONE = 'Europe/Paris'
  186 +
  187 +USE_I18N = True
  188 +
  189 +USE_L10N = True
  190 +
  191 +USE_TZ = True
  192 +
  193 +
  194 +# To find the media files {{ MEDIA_URL }}
  195 +MEDIA_URL = '/public/static/media/'
  196 +
  197 +
  198 +# To find the static files in the app/static/ap/... folders
  199 +STATIC_URL = '/public/static/'
  200 +
  201 +# To find the static files in src/static/. Any local directory can be added to this list.
  202 +STATICFILES_DIRS = (
  203 + os.path.join(BASE_DIR, "misc", "static"),
  204 + )
  205 +
  206 +# Used for deployment (DEBUG = False). Need to run "python manage.py collectstatic" to fill it.
  207 +STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'public', 'static')
  208 +
  209 +
  210 +# EP added
  211 +if not DEBUG:
  212 + '''
  213 + CACHES = {
  214 + 'default': {
  215 + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
  216 + 'LOCATION': '127.0.0.1:11211',
  217 + }
  218 + }
  219 + '''
  220 + CACHES = {
  221 + 'default': {
  222 + 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
  223 + 'LOCATION': '/var/tmp/django_cache',
  224 + }
  225 + }
  226 +
  227 +else:
  228 + CACHES = {
  229 + 'default': {
  230 + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
  231 + }
  232 + }
  233 +
  234 +# from django.core.cache import cache
  235 +# cache.clear()
  236 +
  237 +# CELERY CONFIG
  238 +
  239 +# CELERY_RESULT_BACKEND = 'rpc://'
  240 +CELERY_RESULT_BACKEND = 'amqp'
  241 +
  242 +CELERY_ACCEPT_CONTENT = ['json']
  243 +CELERY_TASK_SERIALIZER = 'json'
  244 +CELERY_RESULT_SERIALIZER = 'json'
  245 +
  246 +CELERY_IMPORTS = (
  247 + "alert_manager.tasks",
  248 + "analyzer.tasks",
  249 + "majordome.tasks",
  250 + "monitoring.tasks",
  251 + "observation_manager.tasks",
  252 + "scheduler.tasks",
  253 +)
  254 +
  255 +# This config allows only 1 process / queue. We replace it by the -c option at celery workers creation.
  256 +# CELERYD_CONCURRENCY = 1
  257 +
  258 +''' Following config is needed for manual purge '''
  259 +CELERY_ACKS_LATE = False
  260 +CELERYD_PREFETCH_MULTIPLIER = 1
  261 +
  262 +CELERY_QUEUES = {
  263 + "alert_listener_q": {"exchange": "alert_listener_q", "routing_key": "alert_listener_q"},
  264 + "analysis_q": {"exchange": "analysis_q", "routing_key": "analysis_q"},
  265 + "system_status_q": {"exchange": "system_status_q", "routing_key": "system_status_q"},
  266 + "change_obs_conditions_q": {"exchange": "change_obs_conditions_q", "routing_key": "change_obs_conditions_q"},
  267 + "monitoring_q": {"exchange": "monitoring_q", "routing_key": "monitoring_q"},
  268 + "scheduling_q": {"exchange": "scheduling_q", "routing_key": "scheduling_q"},
  269 + "execute_sequence_q": {"exchange": "execute_sequence_q", "routing_key": "execute_sequence_q"},
  270 + "execute_plan_vis_q": {"exchange": "execute_plan_vis_q", "routing_key": "execute_plan_vis_q"},
  271 + "execute_plan_nir_q": {"exchange": "execute_plan_nir_q", "routing_key": "execute_plan_nir_q"},
  272 + "create_calibrations_q": {"exchange": "create_calibrations_q", "routing_key": "create_calibrations_q"},
  273 +}
  274 +
  275 +CELERY_ROUTES = {
  276 + "alert_manager.tasks.alert_listener": {"queue": "alert_listener_q"},
  277 + "analyzer.tasks.analysis": {"queue": "analysis_q"},
  278 + "majordome.tasks.execute_sequence": {"queue": "execute_sequence_q"},
  279 + "majordome.tasks.system_pause": {"queue": "system_status_q"},
  280 + "majordome.tasks.system_restart": {"queue": "system_status_q"},
  281 + "majordome.tasks.change_obs_conditions": {"queue": "change_obs_conditions_q"},
  282 + "monitoring.tasks.monitoring": {"queue": "monitoring_q"},
  283 + "observation_manager.tasks.execute_plan_vis": {"queue": "execute_plan_vis_q"},
  284 + "observation_manager.tasks.execute_plan_nir": {"queue": "execute_plan_nir_q"},
  285 + "observation_manager.tasks.create_calibrations": {"queue": "create_calibrations_q"},
  286 + "scheduler.tasks.scheduling": {"queue": "scheduling_q"},
  287 +}
  288 +
  289 +''' Removes pickle warning '''
  290 +CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
src/routine_manager/RequestSerializer.py
@@ -10,8 +10,8 @@ from jdcal import gcal2jd, jd2gcal @@ -10,8 +10,8 @@ from jdcal import gcal2jd, jd2gcal
10 import time 10 import time
11 import datetime 11 import datetime
12 import utils.Logger as L 12 import utils.Logger as L
13 -#import scheduler.tasks as task  
14 -import scheduler.tasks 13 +import scheduler.tasks as task
  14 +#import scheduler.tasks
15 log = L.setupLogger("RequestSerializerLogger", "RequestSerializer") 15 log = L.setupLogger("RequestSerializerLogger", "RequestSerializer")
16 16
17 def prettify(elem): 17 def prettify(elem):
@@ -71,6 +71,7 @@ class RequestSerializer(): @@ -71,6 +71,7 @@ class RequestSerializer():
71 return "Invalid file : " + str(E) 71 return "Invalid file : " + str(E)
72 72
73 self.pyros_user = pyros_user 73 self.pyros_user = pyros_user
  74 + print("RS: pyros user is ", pyros_user)
74 self.request = None 75 self.request = None
75 76
76 """ self.sequences will be a [(seq, album_list), ...], and same thing for album """ 77 """ self.sequences will be a [(seq, album_list), ...], and same thing for album """
@@ -86,8 +87,15 @@ class RequestSerializer(): @@ -86,8 +87,15 @@ class RequestSerializer():
86 self.request.save() 87 self.request.save()
87 for sequence, albums in self.sequences: 88 for sequence, albums in self.sequences:
88 if self.relative: 89 if self.relative:
  90 + # 86400 = nb seconds in 24 h
89 sequence.jd1 = (time.time() + float(sequence.jd1)) / 86400 + TIMESTAMP_JD 91 sequence.jd1 = (time.time() + float(sequence.jd1)) / 86400 + TIMESTAMP_JD
90 sequence.jd2 = (time.time() + float(sequence.jd2)) / 86400 + TIMESTAMP_JD 92 sequence.jd2 = (time.time() + float(sequence.jd2)) / 86400 + TIMESTAMP_JD
  93 + #print("********* jd1,jd2 ", sequence.jd1, sequence.jd2)
  94 +
  95 + # EP avirer
  96 + #sequence.jd1 += float( (1/24)*2 )
  97 + #sequence.jd2 += float( (1/24)*2 )
  98 +
91 sequence.request = self.request 99 sequence.request = self.request
92 sequence.save() 100 sequence.save()
93 for album, plans in albums: 101 for album, plans in albums:
@@ -101,10 +109,12 @@ class RequestSerializer(): @@ -101,10 +109,12 @@ class RequestSerializer():
101 #ret = task.scheduling.delay(first_schedule=False, alert=False) 109 #ret = task.scheduling.delay(first_schedule=False, alert=False)
102 if settings.USE_CELERY: 110 if settings.USE_CELERY:
103 print("RS: schedule WITH CELERY") 111 print("RS: schedule WITH CELERY")
104 - scheduler.tasks.scheduling.delay(first_schedule=False, alert=False) 112 + #ret = scheduler.tasks.scheduling.delay(first_schedule=False, alert=False)
  113 + ret = task.scheduling.delay(first_schedule=False, alert=False)
105 else: 114 else:
106 print("RS: schedule WITHOUT CELERY") 115 print("RS: schedule WITHOUT CELERY")
107 - scheduler.tasks.scheduling().run(first_schedule=False, alert=False) 116 + #ret = scheduler.tasks.scheduling().run(first_schedule=False, alert=False)
  117 + ret = task.scheduling().run(first_schedule=False, alert=False)
108 118
109 return "" 119 return ""
110 120
src/routine_manager/views.py
@@ -48,7 +48,7 @@ def requests_list(request, status=0, message=&quot;&quot;): @@ -48,7 +48,7 @@ def requests_list(request, status=0, message=&quot;&quot;):
48 requests = [] 48 requests = []
49 49
50 for req in requests_objs: 50 for req in requests_objs:
51 - print("- REQ/views: requete", req) 51 + #print("- REQ/views: requete", req)
52 sequences = req.sequences 52 sequences = req.sequences
53 nb_executed = sequences.filter(status=Sequence.EXECUTED).count 53 nb_executed = sequences.filter(status=Sequence.EXECUTED).count
54 nb_cancelled = sequences.filter(Q(status=Sequence.INVALID) | Q(status=Sequence.CANCELLED) 54 nb_cancelled = sequences.filter(Q(status=Sequence.INVALID) | Q(status=Sequence.CANCELLED)
@@ -443,7 +443,7 @@ def submit_request(request, req_id, redir): @@ -443,7 +443,7 @@ def submit_request(request, req_id, redir):
443 scheduler.tasks.scheduling.delay(first_schedule=True, alert=False) 443 scheduler.tasks.scheduling.delay(first_schedule=True, alert=False)
444 else: 444 else:
445 print("WITHOUT CELERY") 445 print("WITHOUT CELERY")
446 - scheduler.tasks.scheduling().delay(first_schedule=True, alert=False) 446 + scheduler.tasks.scheduling().run(first_schedule=True, alert=False)
447 447
448 message = "The request was submitted" 448 message = "The request was submitted"
449 if redir == "action_request": 449 if redir == "action_request":
@@ -464,7 +464,7 @@ def unsubmit_request(request, req_id): @@ -464,7 +464,7 @@ def unsubmit_request(request, req_id):
464 464
465 # TODO: uncomment pour la production 465 # TODO: uncomment pour la production
466 # if req.sequences.filter(Q(status=Sequence.EXECUTED) | Q(status=Sequence.EXECUTING)).exists(): 466 # if req.sequences.filter(Q(status=Sequence.EXECUTED) | Q(status=Sequence.EXECUTING)).exists():
467 -# message = "You can't unsubmit an request with executed sequences" 467 +# message = "You can't unsubmit a request with executed sequences"
468 # return redirect(action_request, req_id=req_id, action="view", status=-1, message=message) 468 # return redirect(action_request, req_id=req_id, action="view", status=-1, message=message)
469 469
470 req.submitted = False 470 req.submitted = False
src/scheduler/Scheduler.py
1 from operator import attrgetter 1 from operator import attrgetter
  2 +
  3 +from scheduler.templatetags.jdconverter import jdtodate
2 from .UserManager import UserManager 4 from .UserManager import UserManager
3 from .Interval import * 5 from .Interval import *
4 from django.db.models import Q 6 from django.db.models import Q
@@ -42,6 +44,7 @@ class Scheduler(IntervalManagement): @@ -42,6 +44,7 @@ class Scheduler(IntervalManagement):
42 ''' 44 '''
43 def copyFromPrevious(self) -> int: 45 def copyFromPrevious(self) -> int:
44 if len(Schedule.objects.all()) == 1: 46 if len(Schedule.objects.all()) == 1:
  47 + print("only 1 schedule available")
45 self.schedule.plan_night_start = self.schedule.plan_start 48 self.schedule.plan_night_start = self.schedule.plan_start
46 if DEBUG_FILE: 49 if DEBUG_FILE:
47 self.log("No schedule found") 50 self.log("No schedule found")
@@ -97,7 +100,11 @@ class Scheduler(IntervalManagement): @@ -97,7 +100,11 @@ class Scheduler(IntervalManagement):
97 self.log("Interval created : " + str(interval.__dict__)) 100 self.log("Interval created : " + str(interval.__dict__))
98 self.removeInvalidSequences() 101 self.removeInvalidSequences()
99 self.determinePriorities() 102 self.determinePriorities()
  103 + print("Sequences bef removeNonEligible are:", len(self.sequences))
  104 + # EP le pb est ici !!!
  105 + #TODO: bugfix time computation EP a virer (remettre)
100 self.removeNonEligible() 106 self.removeNonEligible()
  107 + print("Sequences aft removeNonEligible are:", len(self.sequences))
101 self.sortSequences() 108 self.sortSequences()
102 self.placeSequences() 109 self.placeSequences()
103 return 0 110 return 0
@@ -108,6 +115,7 @@ class Scheduler(IntervalManagement): @@ -108,6 +115,7 @@ class Scheduler(IntervalManagement):
108 def makeSchedule(self) -> Schedule: 115 def makeSchedule(self) -> Schedule:
109 print("In makeSchedule()") 116 print("In makeSchedule()")
110 global SIMULATION 117 global SIMULATION
  118 + # WHY ???
111 SIMULATION = False 119 SIMULATION = False
112 120
113 if self.isFirstSchedule(): 121 if self.isFirstSchedule():
@@ -117,10 +125,17 @@ class Scheduler(IntervalManagement): @@ -117,10 +125,17 @@ class Scheduler(IntervalManagement):
117 #print("It is not the first schedule") 125 #print("It is not the first schedule")
118 self.copyFromPrevious() #TODO trycatch a faire 126 self.copyFromPrevious() #TODO trycatch a faire
119 self.schedule.plan_night_start = self.schedule.plan_start 127 self.schedule.plan_night_start = self.schedule.plan_start
  128 + print("night start is", self.schedule.plan_night_start)
  129 +
  130 + #EP: avirer (add 2 hours)
  131 + #self.schedule.plan_night_start += float( (1/24)*2 )
  132 + #self.schedule.plan_start += float( (1/24)*2 )
120 133
121 - # List of sequences (PLANNED, TOBEPLANNED, PENDING) 134 + # Get all sequences which are PLANNED, TOBEPLANNED, or PENDING
122 self.sequences = list(Sequence.objects.filter(Q(status=Sequence.PLANNED) | Q(status=Sequence.TOBEPLANNED) 135 self.sequences = list(Sequence.objects.filter(Q(status=Sequence.PLANNED) | Q(status=Sequence.TOBEPLANNED)
123 | Q(status=Sequence.PENDING))) 136 | Q(status=Sequence.PENDING)))
  137 + print("**** nb of sequences already available for scheduling", len(self.sequences))
  138 +
124 # List of tuples (sequence, ScheduleHasSequences) for each sequence above and for current schedule 139 # List of tuples (sequence, ScheduleHasSequences) for each sequence above and for current schedule
125 self.sequences = [ 140 self.sequences = [
126 ( 141 (
@@ -129,10 +144,11 @@ class Scheduler(IntervalManagement): @@ -129,10 +144,11 @@ class Scheduler(IntervalManagement):
129 ) 144 )
130 for sequence in self.sequences 145 for sequence in self.sequences
131 ] 146 ]
132 - print("Sequences are:", self.sequences) 147 + print("Sequences BEFORE are:", len(self.sequences))
133 if DEBUG_FILE: 148 if DEBUG_FILE:
134 self.log(str(len(self.sequences)) + " sequences found") 149 self.log(str(len(self.sequences)) + " sequences found")
135 self.computeSchedule() 150 self.computeSchedule()
  151 + print("Sequences AFTER are:", len(self.sequences))
136 self.saveSchedule() 152 self.saveSchedule()
137 if DEBUG_FILE: 153 if DEBUG_FILE:
138 self.log("Saving schedule with " + str(len(self.schedule.sequences.all())) + " sequences") 154 self.log("Saving schedule with " + str(len(self.schedule.sequences.all())) + " sequences")
@@ -156,6 +172,14 @@ class Scheduler(IntervalManagement): @@ -156,6 +172,14 @@ class Scheduler(IntervalManagement):
156 def removeNonEligible(self) -> int: 172 def removeNonEligible(self) -> int:
157 for sequence, shs in list(self.sequences): 173 for sequence, shs in list(self.sequences):
158 overlap = Decimal(min(self.schedule.plan_end, sequence.jd2)) - Decimal(max(self.schedule.plan_start, sequence.jd1)) - self.max_overhead 174 overlap = Decimal(min(self.schedule.plan_end, sequence.jd2)) - Decimal(max(self.schedule.plan_start, sequence.jd1)) - self.max_overhead
  175 + print()
  176 + print("- sequence: ", sequence)
  177 + print("plan start - plan end:", jdtodate(self.schedule.plan_start), "-", jdtodate(self.schedule.plan_end))
  178 + print("jd1-jd2:", jdtodate(sequence.jd1), "-", jdtodate(sequence.jd2))
  179 + print("overlap < duration ?:", overlap, sequence.duration)
  180 + #print("- sequence: ", sequence, "plan start, end, jd1, jd2, overlap", self.schedule.plan_start, self.schedule.plan_end, sequence.jd1, sequence.jd2, overlap)
  181 + #print("- sequence: ", sequence, "plan start", jdtodate(self.schedule.plan_start))
  182 + print()
159 if overlap < sequence.duration: 183 if overlap < sequence.duration:
160 if sequence.jd1 < self.schedule.plan_start: 184 if sequence.jd1 < self.schedule.plan_start:
161 sequence.status = Sequence.UNPLANNABLE 185 sequence.status = Sequence.UNPLANNABLE
src/scheduler/tasks.py
@@ -14,8 +14,11 @@ class scheduling(Task): @@ -14,8 +14,11 @@ class scheduling(Task):
14 print("In scheduling.run()") 14 print("In scheduling.run()")
15 task = TaskId.objects.create(task_id=self.request.id, task="scheduling") 15 task = TaskId.objects.create(task_id=self.request.id, task="scheduling")
16 Log.objects.create(agent='Scheduler', message='Start schedule : ' + str(datetime.datetime.now())) 16 Log.objects.create(agent='Scheduler', message='Start schedule : ' + str(datetime.datetime.now()))
  17 + # This creates a Scheduler (in memory) which creates a Schedule (in DB)
17 self.scheduler = Scheduler() 18 self.scheduler = Scheduler()
18 self.scheduler.setNightLimits(secondsToJulianDate(getNightStart()), secondsToJulianDate(getNightEnd())) 19 self.scheduler.setNightLimits(secondsToJulianDate(getNightStart()), secondsToJulianDate(getNightEnd()))
  20 + print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
19 self.scheduler.makeSchedule() 21 self.scheduler.makeSchedule()
  22 + print("****sched-task: NEW SCHEDULE", self.scheduler.schedule, "*****")
20 Log.objects.create(agent='Scheduler', message='Scheduling finished : ' + str(datetime.datetime.now())) 23 Log.objects.create(agent='Scheduler', message='Scheduling finished : ' + str(datetime.datetime.now()))
21 task.delete() 24 task.delete()
22 \ No newline at end of file 25 \ No newline at end of file
src/scheduler/templatetags/jdconverter.py
@@ -14,6 +14,10 @@ def jdtodate(jd): @@ -14,6 +14,10 @@ def jdtodate(jd):
14 14
15 hour = str(int(date[3] * 24)) 15 hour = str(int(date[3] * 24))
16 hour = hour if len(hour) == 2 else "0%s" % hour 16 hour = hour if len(hour) == 2 else "0%s" % hour
  17 +
  18 + # EP avirer
  19 + #hour = str(int(hour)+2)
  20 +
17 minute = str(int(date[3] * 24 * 60 % 60)) 21 minute = str(int(date[3] * 24 * 60 % 60))
18 minute = minute if len(minute) == 2 else "0%s" % minute 22 minute = minute if len(minute) == 2 else "0%s" % minute
19 second = str(int(date[3] * 24 * 60 * 60 % 60)) 23 second = str(int(date[3] * 24 * 60 * 60 % 60))
src/scheduler/tests.py
@@ -8,6 +8,7 @@ SIMULATION_FILE = &#39;file:./scheduler/sequences_cador.html&#39; @@ -8,6 +8,7 @@ SIMULATION_FILE = &#39;file:./scheduler/sequences_cador.html&#39;
8 8
9 class SchedulerTest(TestCase): 9 class SchedulerTest(TestCase):
10 10
  11 + # (EP) Create a fixture in memory with 1 scheduler, 3 requests belonging to 3 different users
11 def setUp(self): 12 def setUp(self):
12 ''' 13 '''
13 Creates the scheduler 14 Creates the scheduler
@@ -557,16 +558,22 @@ class SchedulerTest(TestCase): @@ -557,16 +558,22 @@ class SchedulerTest(TestCase):
557 558
558 def test_4_seq_eligibility(self): 559 def test_4_seq_eligibility(self):
559 ''' 560 '''
560 - goal: test if inelibigle sequences are programmed 561 + goal: test if ineligible sequences are programmed
561 conditions: only ineligible sequences 562 conditions: only ineligible sequences
562 ''' 563 '''
563 564
564 print("\n===== TEST_4_SEQ_ELIGIBILITY =====\n") 565 print("\n===== TEST_4_SEQ_ELIGIBILITY =====\n")
565 566
  567 + # Check that only 1 EMPTY schedule is available in DB (because of Scheduler() instance created in setup())
  568 + self.assertEqual(len(Schedule.objects.all()) , 1)
  569 + sched = Schedule.objects.order_by('-created')[0]
  570 + print("schedule is", sched)
  571 + self.assertEqual(len(sched.shs.all()), 0)
  572 +
566 self.scheduler.schedule.plan_start = 100 573 self.scheduler.schedule.plan_start = 100
567 self.scheduler.schedule.plan_end = 200 574 self.scheduler.schedule.plan_end = 200
568 575
569 - ''' create the sequences ''' 576 + ''' create 4 sequences (to be planned) with default status TOBEPLANNED '''
570 seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED, 577 seq1 = Sequence.objects.create(request=self.req1, status=Sequence.TOBEPLANNED,
571 name="seq1", jd1=0, jd2=110, priority=1, t_prefered=-1, duration=20) 578 name="seq1", jd1=0, jd2=110, priority=1, t_prefered=-1, duration=20)
572 seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED, 579 seq2 = Sequence.objects.create(request=self.req2, status=Sequence.TOBEPLANNED,
@@ -575,28 +582,38 @@ class SchedulerTest(TestCase): @@ -575,28 +582,38 @@ class SchedulerTest(TestCase):
575 name="seq3", jd1=50, jd2=90, priority=1, t_prefered=-1, duration=20) 582 name="seq3", jd1=50, jd2=90, priority=1, t_prefered=-1, duration=20)
576 seq4 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED, 583 seq4 = Sequence.objects.create(request=self.req3, status=Sequence.TOBEPLANNED,
577 name="seq4", jd1=300, jd2=400, priority=1, t_prefered=-1, duration=20) 584 name="seq4", jd1=300, jd2=400, priority=1, t_prefered=-1, duration=20)
  585 + #for s in (seq1,seq2,seq3,seq4): print(s.status)
  586 +
  587 + # Check that we now have exactly 4 sequences in DB
  588 + self.assertEqual(len(Sequence.objects.all()) , 4)
578 589
579 ''' compute and print the schedule ''' 590 ''' compute and print the schedule '''
580 self.scheduler.makeSchedule() 591 self.scheduler.makeSchedule()
581 592
  593 + # Check that still only 1 schedule available in DB, and 0 sequence in it
  594 + self.assertEqual(len(Schedule.objects.all()) , 1)
  595 + # Get the last (more recent) schedule saved by makeSchedule()
582 sched = Schedule.objects.order_by('-created')[0] 596 sched = Schedule.objects.order_by('-created')[0]
  597 + print("updated schedule is", sched, "with night start", sched.plan_night_start)
583 shs_list = sched.shs.all() 598 shs_list = sched.shs.all()
  599 + # EP added
  600 + self.assertEqual(len(shs_list), 0)
584 nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED]) 601 nbPlanned = len([shs for shs in shs_list if shs.status == Sequence.PLANNED])
  602 + self.assertEqual(nbPlanned, 0)
585 603
  604 + ''' checks sequences status '''
586 seq1 = Sequence.objects.get(name="seq1") 605 seq1 = Sequence.objects.get(name="seq1")
587 seq2 = Sequence.objects.get(name="seq2") 606 seq2 = Sequence.objects.get(name="seq2")
588 seq3 = Sequence.objects.get(name="seq3") 607 seq3 = Sequence.objects.get(name="seq3")
589 seq4 = Sequence.objects.get(name="seq4") 608 seq4 = Sequence.objects.get(name="seq4")
590 609
591 - ''' checks sequences status '''  
592 -  
593 - self.assertEqual(nbPlanned, 0)  
594 - 610 + for s in (seq1,seq2,seq3,seq4): print(s.status)
595 self.assertEqual(seq1.status, Sequence.UNPLANNABLE) 611 self.assertEqual(seq1.status, Sequence.UNPLANNABLE)
596 self.assertEqual(seq2.status, Sequence.TOBEPLANNED) 612 self.assertEqual(seq2.status, Sequence.TOBEPLANNED)
597 self.assertEqual(seq3.status, Sequence.UNPLANNABLE) 613 self.assertEqual(seq3.status, Sequence.UNPLANNABLE)
598 self.assertEqual(seq4.status, Sequence.TOBEPLANNED) 614 self.assertEqual(seq4.status, Sequence.TOBEPLANNED)
599 615
  616 +
600 def test_invalid_sequences(self): 617 def test_invalid_sequences(self):
601 ''' 618 '''
602 goal: test if the scheduler is able to plan invalid sequences (it shouldn't) 619 goal: test if the scheduler is able to plan invalid sequences (it shouldn't)
src/utils/JDManipulator.py
@@ -17,8 +17,10 @@ def getSimTime(): @@ -17,8 +17,10 @@ def getSimTime():
17 current_time = current_time.replace(minute=current_time.minute + 1, second=10) 17 current_time = current_time.replace(minute=current_time.minute + 1, second=10)
18 else: 18 else:
19 current_time = current_time.replace(second=(current_time.second + 10)) 19 current_time = current_time.replace(second=(current_time.second + 10))
  20 +
20 return (time.mktime(current_time.timetuple())) 21 return (time.mktime(current_time.timetuple()))
21 22
  23 +
22 SIM_TIME_START = getSimTime() 24 SIM_TIME_START = getSimTime()
23 25
24 def JulianSeconds(value): 26 def JulianSeconds(value):
@@ -67,6 +69,12 @@ def getNextDefaultNightEnd(): @@ -67,6 +69,12 @@ def getNextDefaultNightEnd():
67 69
68 def getDefaultNightStart(): 70 def getDefaultNightStart():
69 current_time = datetime.datetime.now() 71 current_time = datetime.datetime.now()
  72 + print("*********************")
  73 + print("*********************")
  74 + print("current time is", current_time)
  75 + print("SIM_TIME_START", SIM_TIME_START)
  76 + print("*********************")
  77 + print("*********************")
70 if settings.SIMULATOR: 78 if settings.SIMULATOR:
71 if settings.SIMULATOR: 79 if settings.SIMULATOR:
72 return SIM_TIME_START 80 return SIM_TIME_START