mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 17:22:56 -07:00
Add config import to settings page
This commit is contained in:
parent
06665fdd06
commit
3043956dec
4 changed files with 213 additions and 10 deletions
|
@ -22,6 +22,7 @@ import os
|
|||
import re
|
||||
import shutil
|
||||
import time
|
||||
import threading
|
||||
|
||||
from configobj import ConfigObj
|
||||
|
||||
|
@ -202,6 +203,7 @@ _DO_NOT_IMPORT_KEYS_DOCKER = [
|
|||
]
|
||||
|
||||
IS_IMPORTING = False
|
||||
IMPORT_THREAD = None
|
||||
|
||||
|
||||
def set_is_importing(value):
|
||||
|
@ -209,6 +211,15 @@ def set_is_importing(value):
|
|||
IS_IMPORTING = value
|
||||
|
||||
|
||||
def set_import_thread(config=None, backup=False):
|
||||
global IMPORT_THREAD
|
||||
if config:
|
||||
IMPORT_THREAD = threading.Thread(target=import_tautulli_config,
|
||||
kwargs={'config': config, 'backup': backup})
|
||||
else:
|
||||
IMPORT_THREAD = None
|
||||
|
||||
|
||||
def import_tautulli_config(config=None, backup=False):
|
||||
if backup:
|
||||
# Make a backup of the current config first
|
||||
|
@ -235,6 +246,7 @@ def import_tautulli_config(config=None, backup=False):
|
|||
plexpy.CONFIG.write()
|
||||
|
||||
logger.info("Tautulli Config :: Tautulli config import complete.")
|
||||
set_import_thread(None)
|
||||
set_is_importing(False)
|
||||
|
||||
# Restart to apply changes
|
||||
|
|
|
@ -3876,9 +3876,8 @@ class WebInterface(object):
|
|||
if not config_path:
|
||||
return {'result': 'error', 'message': 'No config specified for import'}
|
||||
|
||||
threading.Thread(target=config.import_tautulli_config,
|
||||
kwargs={'config': config_path,
|
||||
'backup': helpers.bool_true(backup)}).start()
|
||||
config.set_import_thread(config=config_path, backup=helpers.bool_true(backup))
|
||||
|
||||
return {'result': 'success',
|
||||
'message': 'Config import has started. Check the logs to monitor any problems. '
|
||||
'Tautulli will restart automatically.'}
|
||||
|
@ -3896,6 +3895,11 @@ class WebInterface(object):
|
|||
logger.warn("No app specified for import.")
|
||||
return
|
||||
|
||||
@cherrypy.expose
|
||||
@requireAuth(member_of("admin"))
|
||||
def import_config_tool(self, **kwargs):
|
||||
return serve_template(templatename="config_import.html", title="Import Tautulli Config")
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
|
@ -4158,7 +4162,8 @@ class WebInterface(object):
|
|||
def do_state_change(self, signal, title, timer, **kwargs):
|
||||
message = title
|
||||
quote = self.random_arnold_quotes()
|
||||
plexpy.SIGNAL = signal
|
||||
if signal:
|
||||
plexpy.SIGNAL = signal
|
||||
|
||||
if plexpy.CONFIG.HTTP_ROOT.strip('/'):
|
||||
new_http_root = '/' + plexpy.CONFIG.HTTP_ROOT.strip('/') + '/'
|
||||
|
@ -4207,6 +4212,13 @@ class WebInterface(object):
|
|||
def reset_git_install(self, **kwargs):
|
||||
return self.do_state_change('reset', 'Resetting to {}'.format(common.RELEASE), 120)
|
||||
|
||||
@cherrypy.expose
|
||||
@requireAuth(member_of("admin"))
|
||||
def restart_import_config(self, **kwargs):
|
||||
if config.IMPORT_THREAD:
|
||||
config.IMPORT_THREAD.start()
|
||||
return self.do_state_change(None, 'Importing a Config', 15)
|
||||
|
||||
@cherrypy.expose
|
||||
@requireAuth(member_of("admin"))
|
||||
def get_changelog(self, latest_only=False, since_prev_release=False, update_shown=False, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue