Exemplo n.º 1
0
 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(uid=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()
Exemplo n.º 2
0
    def _modify_workflows(self, json_in, trigger):
        from server.flaskserver import running_context

        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(uid=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:
                running_context.controller.schedule_workflows(self.id, new, trigger)
            if removed:
                running_context.controller.scheduler.unschedule_workflows(self.id, removed)
Exemplo n.º 3
0
 def update(self, json_in):
     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)
Exemplo n.º 4
0
 def _start_workflows(self, trigger=None):
     from server.flaskserver import running_context
     trigger = trigger if trigger is not None else construct_trigger(self._reconstruct_scheduler_args())
     running_context.controller.schedule_workflows(self.id, self._get_workflow_uids_as_list(), trigger)