mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Catch config.ParseError
This commit is contained in:
parent
a675202537
commit
9095fc0c7a
2 changed files with 19 additions and 6 deletions
|
@ -160,7 +160,11 @@ def initialize(config_file):
|
||||||
global UMASK
|
global UMASK
|
||||||
global _UPDATE
|
global _UPDATE
|
||||||
|
|
||||||
CONFIG = config.Config(config_file)
|
try:
|
||||||
|
CONFIG = config.Config(config_file)
|
||||||
|
except:
|
||||||
|
raise SystemExit("Unable to initialize Tautulli due to a corrupted config file. Exiting...")
|
||||||
|
|
||||||
CONFIG_FILE = config_file
|
CONFIG_FILE = config_file
|
||||||
|
|
||||||
assert CONFIG is not None
|
assert CONFIG is not None
|
||||||
|
|
|
@ -24,7 +24,7 @@ import shutil
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj, ParseError
|
||||||
|
|
||||||
import plexpy
|
import plexpy
|
||||||
if plexpy.PYTHON2:
|
if plexpy.PYTHON2:
|
||||||
|
@ -228,12 +228,16 @@ def import_tautulli_config(config=None, backup=False):
|
||||||
logger.error("Tautulli Config :: Failed to import Tautulli config: failed to create config backup")
|
logger.error("Tautulli Config :: Failed to import Tautulli config: failed to create config backup")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Create a new Config object with the imported config file
|
||||||
|
try:
|
||||||
|
imported_config = Config(config, is_import=True)
|
||||||
|
except:
|
||||||
|
logger.error("Tautulli Config :: Failed to import Tautulli config: error reading imported config file")
|
||||||
|
return False
|
||||||
|
|
||||||
logger.info("Tautulli Config :: Importing Tautulli config '%s'...", config)
|
logger.info("Tautulli Config :: Importing Tautulli config '%s'...", config)
|
||||||
set_is_importing(True)
|
set_is_importing(True)
|
||||||
|
|
||||||
# Create a new Config object with the imported config file
|
|
||||||
imported_config = Config(config, is_import=True)
|
|
||||||
|
|
||||||
# Remove keys that should not be imported
|
# Remove keys that should not be imported
|
||||||
for key in _DO_NOT_IMPORT_KEYS:
|
for key in _DO_NOT_IMPORT_KEYS:
|
||||||
delattr(imported_config, key)
|
delattr(imported_config, key)
|
||||||
|
@ -298,7 +302,12 @@ class Config(object):
|
||||||
def __init__(self, config_file, is_import=False):
|
def __init__(self, config_file, is_import=False):
|
||||||
""" Initialize the config with values from a file """
|
""" Initialize the config with values from a file """
|
||||||
self._config_file = config_file
|
self._config_file = config_file
|
||||||
self._config = ConfigObj(self._config_file, encoding='utf-8')
|
try:
|
||||||
|
self._config = ConfigObj(self._config_file, encoding='utf-8')
|
||||||
|
except ParseError as e:
|
||||||
|
logger.error("Tautulli Config :: Error reading configuration file: %s", e)
|
||||||
|
raise
|
||||||
|
|
||||||
for key in _CONFIG_DEFINITIONS:
|
for key in _CONFIG_DEFINITIONS:
|
||||||
self.check_setting(key)
|
self.check_setting(key)
|
||||||
if not is_import:
|
if not is_import:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue