Skip to content

Commit

Permalink
Merge pull request #1300 from liiight/cli_config
Browse files Browse the repository at this point in the history
Allow config changing plugins to operate while daemon is running. Fixes #1299
  • Loading branch information
liiight committed Sep 16, 2016
2 parents fc8c2a6 + 00c025f commit 6f71001
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions flexget/manager.py
Expand Up @@ -221,6 +221,15 @@ def tasks(self):
def has_lock(self):
return self._has_lock

@property
def should_reload(self):
""" Add triggers to the list to trigger a config reload from memory. Needed for some options to work while
daemon is running """
reload_triggers = ['execute.cli_config']
if any(getattr(self.options, trigger, False) for trigger in reload_triggers):
return True
return False

def execute(self, options=None, output=None, loglevel=None, priority=1):
"""
Run all (can be limited with options) tasks from the config.
Expand Down Expand Up @@ -262,6 +271,9 @@ def execute(self, options=None, output=None, loglevel=None, priority=1):
# TODO: 1.2 This is a hack to make task priorities work still, not sure if it's the best one
task_names = sorted(task_names, key=lambda t: self.config['tasks'][t].get('priority', 65535))

# A hack to make specific option work by revalidating the config
if self.should_reload:
self.update_config(self.validate_config())
finished_events = []
for task_name in task_names:
task = Task(self, task_name, options=options, output=output, loglevel=loglevel, priority=priority)
Expand Down Expand Up @@ -325,6 +337,7 @@ def handle_cli(self, options=None):
"""
if not options:
options = self.options
self.options = options
command = options.cli_command
command_options = getattr(options, command)
# First check for built-in commands
Expand Down

0 comments on commit 6f71001

Please sign in to comment.