diff --git a/SickBeard.py b/SickBeard.py index 59cc9b75..933bcb1c 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -83,6 +83,7 @@ def loadShowsFromDB(): myDB = db.DBConnection() sqlResults = myDB.select("SELECT * FROM tv_shows") + sickbeard.showList = [] for sqlShow in sqlResults: try: curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"])) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 38be5e02..8da92f76 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -22,7 +22,8 @@ import webbrowser import time import datetime import socket -import os, sys, subprocess, re +import os +import re from urllib2 import getproxies from threading import Lock @@ -90,10 +91,10 @@ traktCheckerScheduler = None showList = None loadingShowList = None -providerList = None -newznabProviderList = None -torrentRssProviderList = None -metadata_provider_dict = None +providerList = [] +newznabProviderList = [] +torrentRssProviderList = [] +metadata_provider_dict = {} NEWEST_VERSION = None NEWEST_VERSION_STRING = None @@ -102,7 +103,6 @@ AUTO_UPDATE = None CUR_COMMIT_HASH = None INIT_LOCK = Lock() -__INITIALIZED__ = False started = False restarted = False @@ -161,7 +161,7 @@ INDEXER_DEFAULT = None INDEXER_TIMEOUT = None SCENE_DEFAULT = None ANIME_DEFAULT = None -PROVIDER_ORDER = None +PROVIDER_ORDER = [] NAMING_MULTI_EP = None NAMING_PATTERN = None @@ -413,17 +413,17 @@ TIME_PRESET_W_SECONDS = None TIMEZONE_DISPLAY = None USE_SUBTITLES = False -SUBTITLES_LANGUAGES = None +SUBTITLES_LANGUAGES = [] SUBTITLES_DIR = '' -SUBTITLES_SERVICES_LIST = None -SUBTITLES_SERVICES_ENABLED = None +SUBTITLES_SERVICES_LIST = [] +SUBTITLES_SERVICES_ENABLED = [] SUBTITLES_HISTORY = False SUBTITLES_FINDER_FREQUENCY = 1 USE_FAILED_DOWNLOADS = False DELETE_FAILED = False -EXTRA_SCRIPTS = None +EXTRA_SCRIPTS = [] GIT_PATH = None @@ -433,8 +433,8 @@ CALENDAR_UNPROTECTED = False TMDB_API_KEY = 'edc5f123313769de83a71e157758030b' -__INITIALIZED__ = False +__INITIALIZED__ = False def initialize(consoleLogging=True): with INIT_LOCK: @@ -478,7 +478,7 @@ def initialize(consoleLogging=True): USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \ AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \ ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \ - ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT, RES + ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT if __INITIALIZED__: return False @@ -1790,18 +1790,4 @@ def getEpList(epIDs, showid=None): curEpObj = curShowObj.getEpisode(int(curEp["season"]), int(curEp["episode"])) epList.append(curEpObj) - return epList - - -def autoreload_shutdown(): - logger.log('SickRage is now auto-reloading, please stand by ...') - - # halt all tasks - halt() - - # save settings - saveAll() - - if CREATEPID: - logger.log(u"Removing pidfile " + str(PIDFILE)) - remove_pid_file(PIDFILE) + return epList \ No newline at end of file diff --git a/sickbeard/db.py b/sickbeard/db.py index b28b3403..b25e107d 100644 --- a/sickbeard/db.py +++ b/sickbeard/db.py @@ -63,7 +63,7 @@ class DBConnection(object): def reconnect(self): """Closes the existing database connection and re-opens it.""" self.close() - self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20) + self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20, check_same_thread=False) self.connection.isolation_level = None if self.row_type == "dict": @@ -164,10 +164,7 @@ class DBConnection(object): logger.log(u"Fatal error executing query: " + ex(e), logger.ERROR) raise - # cleanup - del querylist - - return sqlResult + return sqlResult def action(self, query, args=None, fetchall=False, fetchone=False): @@ -202,7 +199,7 @@ class DBConnection(object): logger.log(u"Fatal error executing query: " + ex(e), logger.ERROR) raise - return sqlResult + return sqlResult def select(self, query, args=None): diff --git a/sickbeard/scene_exceptions.py b/sickbeard/scene_exceptions.py index 75cbdac2..3128091f 100644 --- a/sickbeard/scene_exceptions.py +++ b/sickbeard/scene_exceptions.py @@ -18,6 +18,7 @@ import re import time +import threading import sickbeard from lib import adba @@ -26,6 +27,8 @@ from sickbeard import name_cache from sickbeard import logger from sickbeard import db +scene_lock = threading.Lock() + def shouldRefresh(list): MAX_REFRESH_AGE_SECS = 86400 # 1 day @@ -59,6 +62,7 @@ def get_scene_exceptions(indexer_id, season=-1): if season == 1: # if we where looking for season 1 we can add generic names exceptionsList += get_scene_exceptions(indexer_id, season=-1) + del exceptions return exceptionsList @@ -74,6 +78,7 @@ def get_all_scene_exceptions(indexer_id): exceptionsList[cur_exception["season"]] = [] exceptionsList[cur_exception["season"]].append(cur_exception["show_name"]) + del exceptions return exceptionsList @@ -121,6 +126,10 @@ def get_scene_exception_by_name_multiple(show_name): sickbeard.helpers.sanitizeSceneName(cur_exception_name).lower().replace('.', ' ')): logger.log(u"Scene exception lookup got indexer id " + str(cur_indexer_id) + u", using that", logger.DEBUG) out.append((cur_indexer_id, cur_season)) + + # cleanup + del all_exception_results + if out: return out else: @@ -210,7 +219,6 @@ def retrieve_exceptions(): logger.log(u"No scene exceptions update needed") # cleanup - del existing_exceptions del exception_dict def update_scene_exceptions(indexer_id, scene_exceptions): @@ -222,7 +230,7 @@ def update_scene_exceptions(indexer_id, scene_exceptions): myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=? and custom=1', [indexer_id]) logger.log(u"Updating scene exceptions", logger.MESSAGE) - for cur_season in [-1] + sickbeard.scene_exceptions.get_scene_seasons(indexer_id): + for cur_season in [-1] + get_scene_seasons(indexer_id): for cur_exception in scene_exceptions: myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season, custom) VALUES (?,?,?,?)", [indexer_id, cur_exception, cur_season, 1])