def initialize_user_preferences(): """Initialize any plugins that were installed via pip. This will parse out all the default preference values into one dictionary for later use in the API. """ manager = StoryboardPluginLoader( namespace='storyboard.plugin.user_preferences') if manager.extensions: manager.map(load_preferences, PREFERENCE_DEFAULTS)
def update_scheduler(): """Update the jobs loaded into the scheduler. This runs every minute to keep track of anything that's since been loaded into our execution hooks. """ global SCHEDULER if not SCHEDULER: LOG.warning("Scheduler does not exist, cannot update it.") return # Load all plugins that are registered and load them into the scheduler. loader = StoryboardPluginLoader(namespace="storyboard.plugin.scheduler") loaded_plugins = [SCHEDULE_MANAGER_ID] if loader.extensions: loader.map(add_plugins, loaded_plugins) # Now manually go through the list of jobs in the scheduler and remove # any that haven't been loaded, since some might have been uninstalled. for job in SCHEDULER.get_jobs(): if job.id not in loaded_plugins: LOG.info('Removing Job: %s' % (job.id, )) SCHEDULER.remove_job(job.id)