コード例 #1
0
 def _start_workflows(self, trigger=None):
     from flask import current_app
     trigger = trigger if trigger is not None else construct_trigger(
         self._reconstruct_scheduler_args())
     current_app.running_context.scheduler.schedule_workflows(
         self.id, execute_workflow_helper, self._get_workflow_ids_as_list(),
         trigger)
コード例 #2
0
ファイル: scheduledtasks.py プロジェクト: krzim/triple-play
 def __init__(self, name, description='', status='running', workflows=None, task_trigger=None):
     self.name = name
     self.description = description
     if workflows is not None:
         for workflow in set(workflows):
             self.workflows.append(ScheduledWorkflow(workflow_id=workflow))
     if task_trigger is not None:
         construct_trigger(task_trigger)  # Throws an error if the args are invalid
         self.trigger_type = task_trigger['type']
         self.trigger_args = json.dumps(task_trigger['args'])
     else:
         self.trigger_type = 'unspecified'
         self.trigger_args = '{}'
     self.status = status if status in ('running', 'stopped') else 'running'
     if self.status == 'running' and self.trigger_type != 'unspecified':
         self._start_workflows()
コード例 #3
0
ファイル: scheduledtasks.py プロジェクト: krzim/triple-play
    def _modify_workflows(self, json_in, trigger):
        from flask import current_app

        new, removed = self.__get_different_workflows(json_in)
        for workflow in self.workflows:
            self.workflows.remove(workflow)
        for workflow in json_in['workflows']:
            self.workflows.append(ScheduledWorkflow(workflow_id=workflow))
        if self.trigger_type != 'unspecified' and self.status == 'running':
            trigger = trigger if trigger is not None else construct_trigger(self._reconstruct_scheduler_args())
            if new:
                current_app.running_context.scheduler.schedule_workflows(self.id,
                                                                         current_app.running_context.executor.execute_workflow,
                                                                         new, trigger)
            if removed:
                current_app.running_context.scheduler.unschedule_workflows(self.id, removed)
コード例 #4
0
ファイル: scheduledtasks.py プロジェクト: krzim/triple-play
    def update(self, json_in):
        """Updates this task from a JSON representation of it

        Args:
            json_in (dict): The JSON representation of the updated task
        """
        trigger = None
        if 'task_trigger' in json_in and json_in['task_trigger']:
            trigger = construct_trigger(json_in['task_trigger'])  # Throws an error if the args are invalid
            self._update_scheduler(trigger)
            self.trigger_type = json_in['task_trigger']['type']
            self.trigger_args = json.dumps(json_in['task_trigger']['args'])
        if 'name' in json_in:
            self.name = json_in['name']
        if 'description' in json_in:
            self.description = json_in['description']
        if 'workflows' in json_in and json_in['workflows']:
            self._modify_workflows(json_in, trigger=trigger)
        if 'status' in json_in and json_in['status'] != self.status:
            self._update_status(json_in)