Exemple #1
0
    def resolve_dependencies(self,
                             exclude_optional_tasks=None,
                             exclude_tasks=None,
                             exclude_all_optional=False):
        self._exclude_optional_tasks = as_task_name_list(exclude_optional_tasks
                                                         or [])
        self._exclude_tasks = as_task_name_list(exclude_tasks or [])
        self._exclude_all_optional = exclude_all_optional

        for task in self._tasks.values():
            self._execute_before[task.name] = []
            self._execute_after[task.name] = []
            self._task_dependencies[task.name] = []

            for d in task.dependencies:
                add_dependency = True
                if not self.has_task(d):
                    raise MissingTaskDependencyException(task.name, d)
                task_dependencies = self._task_dependencies[task.name]
                for index, existing_dependency in enumerate(task_dependencies):
                    if existing_dependency.name == d.name:
                        if existing_dependency.optional != d.optional:
                            if existing_dependency.optional:
                                task_dependencies[index] = TaskDependency(
                                    existing_dependency.name)
                                self.logger.debug(
                                    "Converting optional dependency '%s' of task '%s' into required",
                                    existing_dependency, task.name)
                            else:
                                self.logger.debug(
                                    "Ignoring '%s' as optional dependency of task '%s' - already required",
                                    existing_dependency, task.name)
                        add_dependency = False
                if add_dependency:
                    self._task_dependencies[task.name].append(
                        TaskDependency(self.get_task(d), d.optional))
                    self.logger.debug(
                        "Adding '%s' as a dependency of task '%s'", d,
                        task.name)

        for action in self._actions.values():
            for task in action.execute_before:
                if not self.has_task(task):
                    raise MissingActionDependencyException(action.name, task)
                self._execute_before[task].append(action)
                self.logger.debug("Adding before action '%s' for task '%s'",
                                  action.name, task)

            for task in action.execute_after:
                if not self.has_task(task):
                    raise MissingActionDependencyException(action.name, task)
                self._execute_after[task].append(action)
                self.logger.debug("Adding after action '%s' for task '%s'",
                                  action.name, task)

        self._dependencies_resolved = True
Exemple #2
0
    def resolve_dependencies(self, exclude_optional_tasks=None, exclude_tasks=None):
        self._exclude_optional_tasks = as_task_name_list(exclude_optional_tasks or [])
        self._exclude_tasks = as_task_name_list(exclude_tasks or [])

        for task in self._tasks.values():
            self._execute_before[task.name] = []
            self._execute_after[task.name] = []
            self._task_dependencies[task.name] = []
            if self.is_task_excluded(task.name) or self.is_optional_task_excluded(task.name):
                self.logger.debug("Skipping resolution for excluded task '%s'", task.name)
                continue
            for d in task.dependencies:
                if not self.has_task(d):
                    raise MissingTaskDependencyException(task.name, d)
                if self.is_optional_task_excluded(d):
                    raise RequiredTaskExclusionException(task.name, d)
                if not self.is_task_excluded(d):
                    self._task_dependencies[task.name].append(self.get_task(d))
                    self.logger.debug("Adding '%s' as a required dependency of task '%s'", d, task.name)

            for d in task.optional_dependencies:
                if not self.has_task(d):
                    raise MissingTaskDependencyException(task.name, d)
                if not (self.is_task_excluded(d) or self.is_optional_task_excluded(d)):
                    self._task_dependencies[task.name].append(self.get_task(d))
                    self.logger.debug("Adding '%s' as an optional dependency of task '%s'", d, task.name)

        for action in self._actions.values():
            for task in action.execute_before:
                if not self.has_task(task):
                    raise MissingActionDependencyException(action.name, task)
                self._execute_before[task].append(action)
                self.logger.debug("Adding before action '%s' for task '%s'", action.name, task)

            for task in action.execute_after:
                if not self.has_task(task):
                    raise MissingActionDependencyException(action.name, task)
                self._execute_after[task].append(action)
                self.logger.debug("Adding after action '%s' for task '%s'", action.name, task)

        self._dependencies_resolved = True
Exemple #3
0
    def resolve_dependencies(self):
        for task in self._tasks.values():
            self._execute_before[task.name] = []
            self._execute_after[task.name] = []
            self._task_dependencies[task.name] = []
            for d in task.dependencies:
                if not self.has_task(d):
                    raise MissingTaskDependencyException(task.name, d)
                self._task_dependencies[task.name].append(self.get_task(d))

        for action in self._actions.values():
            for task in action.execute_before:
                if not self.has_task(task):
                    raise MissingActionDependencyException(action.name, task)
                self._execute_before[task].append(action)

            for task in action.execute_after:
                if not self.has_task(task):
                    raise MissingActionDependencyException(action.name, task)
                self._execute_after[task].append(action)

        self._dependencies_resolved = True