mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Remove unused config keys
This commit is contained in:
parent
4f8a462041
commit
fbfedb2e62
5 changed files with 3 additions and 610 deletions
|
@ -3816,129 +3816,6 @@ class ZAPIER(Notifier):
|
|||
return config_option
|
||||
|
||||
|
||||
def upgrade_config_to_db():
|
||||
logger.info("Tautulli Notifiers :: Upgrading to new notification system...")
|
||||
|
||||
# Set flag first in case something fails we don't want to keep re-adding the notifiers
|
||||
plexpy.CONFIG.__setattr__('UPDATE_NOTIFIERS_DB', 0)
|
||||
plexpy.CONFIG.write()
|
||||
|
||||
# Config section names from the {new: old} config
|
||||
section_overrides = {'xbmc': 'XBMC',
|
||||
'nma': 'NMA',
|
||||
'pushbullet': 'PushBullet',
|
||||
'osx': 'OSX_Notify',
|
||||
'ifttt': 'IFTTT'
|
||||
}
|
||||
|
||||
# Config keys from the {new: old} config
|
||||
config_key_overrides = {'plex': {'hosts': 'client_host'},
|
||||
'facebook': {'access_token': 'token',
|
||||
'group_id': 'group',
|
||||
'incl_poster': 'incl_card'},
|
||||
'join': {'api_key': 'apikey',
|
||||
'device_id': 'deviceid'},
|
||||
'hipchat': {'hook': 'url',
|
||||
'incl_poster': 'incl_card'},
|
||||
'nma': {'api_key': 'apikey'},
|
||||
'osx': {'notify_app': 'app'},
|
||||
'prowl': {'key': 'keys'},
|
||||
'pushalot': {'api_key': 'apikey'},
|
||||
'pushbullet': {'api_key': 'apikey',
|
||||
'device_id': 'deviceid'},
|
||||
'pushover': {'api_token': 'apitoken',
|
||||
'key': 'keys'},
|
||||
'scripts': {'script_folder': 'folder'},
|
||||
'slack': {'incl_poster': 'incl_card'}
|
||||
}
|
||||
|
||||
# Get Monitoring config section
|
||||
monitoring = plexpy.CONFIG._config['Monitoring']
|
||||
|
||||
# Get the new default notification subject and body text
|
||||
defualt_subject_text = {a['name']: a['subject'] for a in available_notification_actions()}
|
||||
defualt_body_text = {a['name']: a['body'] for a in available_notification_actions()}
|
||||
|
||||
# Get the old notification subject and body text
|
||||
notify_text = {}
|
||||
for action in get_notify_actions():
|
||||
subject_key = 'notify_' + action + '_subject_text'
|
||||
body_key = 'notify_' + action + '_body_text'
|
||||
notify_text[action + '_subject'] = monitoring.get(subject_key, defualt_subject_text[action])
|
||||
notify_text[action + '_body'] = monitoring.get(body_key, defualt_body_text[action])
|
||||
|
||||
# Check through each notification agent
|
||||
for agent in get_notify_agents():
|
||||
agent_id = AGENT_IDS[agent]
|
||||
|
||||
# Get the old config section for the agent
|
||||
agent_section = section_overrides.get(agent, agent.capitalize())
|
||||
agent_config = plexpy.CONFIG._config.get(agent_section)
|
||||
agent_config_key = agent_section.lower()
|
||||
|
||||
# Make sure there is an existing config section (to prevent adding v2 agents)
|
||||
if not agent_config:
|
||||
continue
|
||||
|
||||
# Get all the actions for the agent
|
||||
agent_actions = {}
|
||||
for action in get_notify_actions():
|
||||
a_key = agent_config_key + '_' + action
|
||||
agent_actions[action] = helpers.cast_to_int(agent_config.get(a_key, 0))
|
||||
|
||||
# Check if any of the actions were enabled
|
||||
# If so, the agent will be added to the database
|
||||
if any(agent_actions.values()):
|
||||
# Get the new default config for the agent
|
||||
notifier_default_config = get_agent_class(agent_id).config
|
||||
|
||||
# Update the new config with the old config values
|
||||
notifier_config = {}
|
||||
for conf, val in notifier_default_config.items():
|
||||
c_key = agent_config_key + '_' + config_key_overrides.get(agent, {}).get(conf, conf)
|
||||
notifier_config[agent + '_' + conf] = agent_config.get(c_key, val)
|
||||
|
||||
# Special handling for scripts - one script with multiple actions
|
||||
if agent == 'scripts':
|
||||
# Get the old script arguments
|
||||
script_args = monitoring.get('notify_scripts_args_text', '')
|
||||
|
||||
# Get the old scripts for each action
|
||||
action_scripts = {}
|
||||
for action in get_notify_actions():
|
||||
s_key = agent + '_' + action + '_script'
|
||||
action_scripts[action] = agent_config.get(s_key, '')
|
||||
|
||||
# Reverse the dict to {script: [actions]}
|
||||
script_actions = {}
|
||||
for k, v in action_scripts.items():
|
||||
if v: script_actions.setdefault(v, set()).add(k)
|
||||
|
||||
# Add a new script notifier for each script if the action was enabled
|
||||
for script, actions in script_actions.items():
|
||||
if any(agent_actions[a] for a in actions):
|
||||
temp_config = notifier_config
|
||||
temp_config.update({a: 0 for a in agent_actions})
|
||||
temp_config.update({a + '_subject': '' for a in agent_actions})
|
||||
for a in actions:
|
||||
if agent_actions[a]:
|
||||
temp_config[a] = agent_actions[a]
|
||||
temp_config[a + '_subject'] = script_args
|
||||
temp_config[agent + '_script'] = script
|
||||
|
||||
# Add a new notifier and update the config
|
||||
notifier_id = add_notifier_config(agent_id=agent_id)
|
||||
set_notifier_config(notifier_id=notifier_id, agent_id=agent_id, **temp_config)
|
||||
|
||||
else:
|
||||
notifier_config.update(agent_actions)
|
||||
notifier_config.update(notify_text)
|
||||
|
||||
# Add a new notifier and update the config
|
||||
notifier_id = add_notifier_config(agent_id=agent_id)
|
||||
set_notifier_config(notifier_id=notifier_id, agent_id=agent_id, **notifier_config)
|
||||
|
||||
|
||||
def check_browser_enabled():
|
||||
global BROWSER_NOTIFIERS
|
||||
BROWSER_NOTIFIERS = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue