Exemplo n.º 1
0
 def test_task_scheduler_enabled_3(self):
     task = TaskSchedule()
     task.interval = 1
     task.start = datetime.datetime.now()
     task.lastrun = datetime.datetime.now() - datetime.timedelta(
         seconds=task.interval)
     self.assertTrue(task.is_time_to_run())
Exemplo n.º 2
0
    microsecond=0, second=0, minute=0) + datetime.timedelta(hours=1)
CAMERA.interval = 60 * APP.configuration.get('schedule.camera.minutes')

TEMPERATURE = TaskSchedule(run_on_init=True)
TEMPERATURE.start = datetime.datetime.now().replace(
    microsecond=0, second=0, minute=0) + datetime.timedelta(hours=1)
TEMPERATURE.interval = 60 * APP.configuration.get(
    'schedule.temperature.minutes')

UPDATEWEB = TaskSchedule(run_on_init=False)
UPDATEWEB.interval = 60 * APP.configuration.get(
    'update.fullcycleweb.interval.minutes')

while True:
    try:
        if MONITOR.is_time_to_run():
            print("[{0}] Time to monitor".format(APP.now()))
            print('Pushing monitor command to {0}.'.format(
                QueueName.Q_MONITOR))
            APP.send(QueueName.Q_MONITOR, 'monitor')
            MONITOR.lastrun = datetime.datetime.now()

        if DISCOVER.is_time_to_run():
            print("[{0}] Time to discover".format(APP.now()))
            print('Pushing discover command to {0}.'.format(
                QueueName.Q_DISCOVER))
            APP.send(QueueName.Q_DISCOVER, 'discover')
            DISCOVER.lastrun = datetime.datetime.now()

        if CAMERA.is_time_to_run():
            if APP.configuration.get('camera.size') is not None:
Exemplo n.º 3
0
 def test_task_scheduler_runinit(self):
     task = TaskSchedule(run_on_init=True)
     task.interval = 0
     self.assertFalse(task.is_time_to_run())
Exemplo n.º 4
0
 def test_task_scheduler_disabled(self):
     task = TaskSchedule()
     task.interval = 0
     self.assertFalse(task.is_time_to_run())
Exemplo n.º 5
0
 def test_task_scheduler_enabled(self):
     task = TaskSchedule(run_on_init=True)
     task.interval = 1
     self.assertTrue(task.is_time_to_run())
Exemplo n.º 6
0
 def test_task_scheduler_not_run_yet(self):
     task = TaskSchedule()
     task.interval = 1
     task.start = datetime.datetime.now()
     task.lastrun = datetime.datetime.now()
     self.assertFalse(task.is_time_to_run())
Exemplo n.º 7
0
 def test_task_scheduler_enabled_2(self):
     task = TaskSchedule()
     task.start = datetime.datetime.now()
     task.interval = 1
     task.lastrun = None
     self.assertTrue(task.is_time_to_run())