Commit b5777246 authored by echel0n's avatar echel0n

Refactored SystemExit messages to be handled by logger instead.

Added proper defaults for legacy encrypt version and secret when not present in config, resolves issues for Synology devices.
parent 58a72c5a
......@@ -357,9 +357,8 @@ def main():
except (SystemExit, KeyboardInterrupt):
if app:
app.shutdown()
except Exception as e:
except Exception:
traceback.print_exc()
if __name__ == '__main__':
main()
......@@ -235,10 +235,7 @@ class Core(object):
if success:
self.main_db = MainDB(self.db_type, self.db_prefix, self.db_host, self.db_port, self.db_username, self.db_password)
self.cache_db = CacheDB(self.db_type, self.db_prefix, self.db_host, self.db_port, self.db_username, self.db_password)
# configure_regions(self.cache_dir, replace_existing_backend=True)
shutil.rmtree(os.path.abspath(os.path.join(self.data_dir, 'restore')), ignore_errors=True)
# else:
# configure_regions(self.cache_dir)
# migrate old database file names to new ones
if os.path.isfile(os.path.abspath(os.path.join(self.data_dir, 'sickbeard.db'))):
......
......@@ -1368,9 +1368,11 @@ class Config(object):
if not os.access(config_file, os.W_OK):
if os.path.isfile(config_file):
raise SystemExit("Config file '{}' must be writeable.".format(config_file))
sickrage.app.log.warning("Config file '{}' must be writeable.".format(config_file))
raise SystemExit
elif not os.access(os.path.dirname(config_file), os.W_OK):
raise SystemExit("Config file root dir '{}' must be writeable.".format(os.path.dirname(config_file)))
sickrage.app.log.warning("Config file root dir '{}' must be writeable.".format(os.path.dirname(config_file)))
raise SystemExit
# decrypt config
self.config_obj = ConfigObj(encoding='utf8')
......@@ -1378,7 +1380,8 @@ class Config(object):
try:
self.config_obj = self.decrypt_config(config_file)
except Exception:
raise SystemExit("Unable to decrypt config file {}, config is most likely corrupted and needs to be deleted.".format(config_file))
sickrage.app.log.error("Unable to decrypt config file {}, config is most likely corrupted and needs to be deleted.".format(config_file))
raise SystemExit
# use defaults
if defaults:
......@@ -2389,8 +2392,8 @@ class Config(object):
# old encryption from python 2
config_obj = ConfigObj(config_file, encoding='utf8')
config_obj.walk(self.legacy_decrypt,
encryption_version=int(config_obj.get('General').get('encryption_version')),
encryption_secret=config_obj.get('General').get('encryption_secret'),
encryption_version=int(config_obj.get('General').get('encryption_version', 0)),
encryption_secret=config_obj.get('General').get('encryption_secret', ''),
raise_errors=False)
return config_obj
......
......@@ -23,7 +23,6 @@
import base64
import ctypes
import datetime
import errno
import glob
import hashlib
import os
......@@ -37,6 +36,7 @@ import string
import tempfile
import time
import traceback
import unicodedata
import uuid
import webbrowser
import zipfile
......@@ -44,9 +44,9 @@ from collections import OrderedDict
from contextlib import contextmanager
from urllib.parse import uses_netloc, urlsplit, urlunsplit, urljoin
import errno
import rarfile
import requests
import unicodedata
from bs4 import BeautifulSoup
import sickrage
......@@ -1013,10 +1013,7 @@ def restore_app_data(srcDir, dstDir):
# cache
if os.path.exists(os.path.join(srcDir, 'cache')):
if os.path.exists(os.path.join(dstDir, 'cache')):
move_file(os.path.join(dstDir, 'cache'), os.path.join(dstDir, '{}_{}.bak'
.format('cache',
datetime.datetime.now().strftime(
'%Y%m%d_%H%M%S'))))
move_file(os.path.join(dstDir, 'cache'), os.path.join(dstDir, '{}_{}.bak'.format('cache', datetime.datetime.now().strftime('%Y%m%d_%H%M%S'))))
move_file(os.path.join(srcDir, 'cache'), dstDir)
return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment