def get_schedule_token(self, workflow):
     schedule_config = self._repository.get_schedule(workflow)
     timestamp = schedule_to_timestamp(schedule_config.time,
                                       schedule_config.start_date)
     recurrence = recurrence_str_to_sec(schedule_config.recurrence)
     overrun_policy = OverrunPolicy.from_string(
         schedule_config.overrun_policy)
     schedule = WorkflowSchedule(
         next_run_time=timestamp,
         recurrence_seconds=recurrence,
         overrun_policy=overrun_policy,
         workflow=schedule_config.workflow,
         emails=schedule_config.emails,
         #TODO(mao): to make it flexible that allow users specify through UI
         max_running_instances=PinballConfig.DEFAULT_MAX_WORKFLOW_RUNNING_INSTANCES)
     schedule.advance_next_run_time()
     timestamp = schedule.next_run_time
     token_name = (
         Name(workflow=schedule_config.workflow
              ).get_workflow_schedule_token_name())
     return Token(name=token_name, owner='parser',
                  expirationTime=timestamp,
                  data=pickle.dumps(schedule))
 def get_schedule_token(self, workflow):
     schedule_config = self._repository.get_schedule(workflow)
     timestamp = schedule_to_timestamp(schedule_config.time,
                                       schedule_config.start_date)
     recurrence = recurrence_str_to_sec(schedule_config.recurrence)
     overrun_policy = OverrunPolicy.from_string(
         schedule_config.overrun_policy)
     schedule = WorkflowSchedule(
         next_run_time=timestamp,
         recurrence_seconds=recurrence,
         overrun_policy=overrun_policy,
         workflow=schedule_config.workflow,
         emails=schedule_config.emails,
         #TODO(mao): to make it flexible that allow users specify through UI
         max_running_instances=PinballConfig.
         DEFAULT_MAX_WORKFLOW_RUNNING_INSTANCES)
     schedule.advance_next_run_time()
     timestamp = schedule.next_run_time
     token_name = (Name(workflow=schedule_config.workflow).
                   get_workflow_schedule_token_name())
     return Token(name=token_name,
                  owner='parser',
                  expirationTime=timestamp,
                  data=pickle.dumps(schedule))
Beispiel #3
0
 def test_recurrence_str_to_sec(self):
     self.assertEqual(10 * 60, recurrence_str_to_sec('10M'))
     self.assertEqual(10 * 60 * 60, recurrence_str_to_sec('10H'))
     self.assertEqual(10 * 24 * 60 * 60, recurrence_str_to_sec('10d'))
     self.assertEqual(10 * 7 * 24 * 60 * 60, recurrence_str_to_sec('10w'))
     self.assertIsNone(recurrence_str_to_sec('10Y'))
Beispiel #4
0
 def test_recurrence_str_to_sec(self):
     self.assertEqual(10 * 60, recurrence_str_to_sec('10M'))
     self.assertEqual(10 * 60 * 60, recurrence_str_to_sec('10H'))
     self.assertEqual(10 * 24 * 60 * 60, recurrence_str_to_sec('10d'))
     self.assertEqual(10 * 7 * 24 * 60 * 60, recurrence_str_to_sec('10w'))
     self.assertIsNone(recurrence_str_to_sec('10Y'))