Example #1
0
    def create_tasks(self):
        """Creates instances of all configured tasks"""
        from flexget.task import Task
        # Clear tasks dict
        self.tasks = {}

        # Backwards compatibility with feeds key
        if 'feeds' in self.config:
            log.warning('`feeds` key has been deprecated and replaced by `tasks`. Please update your config.')
            if 'tasks' in self.config:
                log.error('You have defined both `feeds` and `tasks`. Stop that.')
            self.config['tasks'] = self.config.pop('feeds')
        # construct task list
        tasks = self.config.get('tasks', {}).keys()
        for name in tasks:
            # Make sure numeric task names are turned into strings. #1763, #1961
            if not isinstance(name, basestring):
                self.config['tasks'][unicode(name)] = self.config['tasks'].pop(name)
                name = unicode(name)
            # create task
            task = Task(self, name, self.config['tasks'][name])
            # if task name is prefixed with _ it's disabled
            if name.startswith('_'):
                task.enabled = False
            self.tasks[name] = task
Example #2
0
    def create_tasks(self):
        """Creates instances of all configured tasks"""
        from flexget.task import Task
        # Clear tasks dict
        self.tasks = {}

        # Backwards compatibility with feeds key
        if 'feeds' in self.config:
            log.warning(
                '`feeds` key has been deprecated and replaced by `tasks`. Please update your config.'
            )
            if 'tasks' in self.config:
                log.error(
                    'You have defined both `feeds` and `tasks`. Stop that.')
            self.config['tasks'] = self.config.pop('feeds')
        # construct task list
        tasks = self.config.get('tasks', {}).keys()
        for name in tasks:
            # Make sure numeric task names are turned into strings. #1763
            name = unicode(name)
            # create task
            task = Task(self, name, self.config['tasks'][name])
            # if task name is prefixed with _ it's disabled
            if name.startswith('_'):
                task.enabled = False
            self.tasks[name] = task
Example #3
0
    def update_tasks(self):
        """Updates instances of all configured tasks from config"""
        from flexget.task import Task

        if not isinstance(self.config['tasks'], dict):
            log.critical('Tasks is in wrong datatype, please read configuration guides')
            return

        # construct task list
        for name in self.config.get('tasks', {}):
            if not isinstance(self.config['tasks'][name], dict):
                continue
            if name in self.tasks:
                # This task already has an instance, update it
                self.tasks[name].config = deepcopy(self.config['tasks'][name])
                if not name.startswith('_'):
                    self.tasks[name].enabled = True
            else:
                # Create task
                task = Task(self, name, deepcopy(self.config['tasks'][name]))
                # If task name is prefixed with _ it's disabled
                if name.startswith('_'):
                    task.enabled = False
                self.tasks[name] = task
        # Delete any task instances that are no longer in the config
        for name in [n for n in self.tasks if n not in self.config['tasks']]:
            del self.tasks[name]
Example #4
0
    def update_tasks(self):
        """Updates instances of all configured tasks from config"""
        from flexget.task import Task

        if not isinstance(self.config['tasks'], dict):
            log.critical(
                'Tasks is in wrong datatype, please read configuration guides')
            return

        # construct task list
        for name in self.config.get('tasks', {}):
            if not isinstance(self.config['tasks'][name], dict):
                continue
            if name in self.tasks:
                # This task already has an instance, update it
                self.tasks[name].config = deepcopy(self.config['tasks'][name])
                if not name.startswith('_'):
                    self.tasks[name].enabled = True
            else:
                # Create task
                task = Task(self, name, deepcopy(self.config['tasks'][name]))
                # If task name is prefixed with _ it's disabled
                if name.startswith('_'):
                    task.enabled = False
                self.tasks[name] = task
        # Delete any task instances that are no longer in the config
        for name in [n for n in self.tasks if n not in self.config['tasks']]:
            del self.tasks[name]