1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

Removed maintance schedualer and moved the routines from it to happen before a search is started to ensure things are up to date and to stop waking up synology devices, regexes also made less greedy.

This commit is contained in:
echel0n 2014-07-07 14:30:27 -07:00
parent 3eab86478a
commit c8d899ad66
7 changed files with 31 additions and 81 deletions

View File

@ -60,7 +60,7 @@ import sickbeard
from sickbeard import db from sickbeard import db
from sickbeard.tv import TVShow from sickbeard.tv import TVShow
from sickbeard import logger from sickbeard import logger, network_timezones, failed_history, name_cache
from sickbeard.webserveInit import SRWebServer from sickbeard.webserveInit import SRWebServer
from sickbeard.version import SICKBEARD_VERSION from sickbeard.version import SICKBEARD_VERSION
from sickbeard.databases.mainDB import MIN_DB_VERSION from sickbeard.databases.mainDB import MIN_DB_VERSION
@ -313,6 +313,16 @@ class SickRage(object):
# Fire up all our threads # Fire up all our threads
sickbeard.start() sickbeard.start()
# Build internal name cache
name_cache.buildNameCache()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
# Start an update if we're supposed to # Start an update if we're supposed to
if self.forceUpdate or sickbeard.UPDATE_SHOWS_ON_START: if self.forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable

View File

@ -41,7 +41,6 @@ from sickbeard import helpers, db, exceptions, show_queue, search_queue, schedul
from sickbeard import logger from sickbeard import logger
from sickbeard import naming from sickbeard import naming
from sickbeard import dailysearcher from sickbeard import dailysearcher
from sickbeard import maintenance
from sickbeard import scene_numbering, scene_exceptions, name_cache from sickbeard import scene_numbering, scene_exceptions, name_cache
from indexers.indexer_api import indexerApi from indexers.indexer_api import indexerApi
from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, indexer_episodenotfound, \ from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, indexer_episodenotfound, \
@ -76,7 +75,6 @@ PIDFILE = ''
DAEMON = None DAEMON = None
NO_RESIZE = False NO_RESIZE = False
maintenanceScheduler = None
dailySearchScheduler = None dailySearchScheduler = None
backlogSearchScheduler = None backlogSearchScheduler = None
showUpdateScheduler = None showUpdateScheduler = None
@ -479,7 +477,7 @@ def initialize(consoleLogging=True):
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \ USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \ AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \ ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT ANIME_SPLIT_HOME, SCENE_DEFAULT
if __INITIALIZED__: if __INITIALIZED__:
return False return False
@ -957,10 +955,6 @@ def initialize(consoleLogging=True):
threadName="CHECKVERSION", threadName="CHECKVERSION",
silent=False) silent=False)
maintenanceScheduler = scheduler.Scheduler(maintenance.Maintenance(),
cycleTime=datetime.timedelta(hours=1),
threadName="MAINTENANCE")
showQueueScheduler = scheduler.Scheduler(show_queue.ShowQueue(), showQueueScheduler = scheduler.Scheduler(show_queue.ShowQueue(),
cycleTime=datetime.timedelta(seconds=3), cycleTime=datetime.timedelta(seconds=3),
threadName="SHOWQUEUE") threadName="SHOWQUEUE")
@ -1123,7 +1117,7 @@ def initialize(consoleLogging=True):
def start(): def start():
global __INITIALIZED__, maintenanceScheduler, backlogSearchScheduler, \ global __INITIALIZED__, backlogSearchScheduler, \
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \ showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \ properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
subtitlesFinderScheduler, USE_SUBTITLES,traktCheckerScheduler, \ subtitlesFinderScheduler, USE_SUBTITLES,traktCheckerScheduler, \
@ -1133,9 +1127,6 @@ def start():
if __INITIALIZED__: if __INITIALIZED__:
# start the maintenance scheduler
maintenanceScheduler.thread.start()
# start the daily search scheduler # start the daily search scheduler
dailySearchScheduler.thread.start() dailySearchScheduler.thread.start()
@ -1171,7 +1162,7 @@ def start():
def halt(): def halt():
global __INITIALIZED__, maintenanceScheduler, backlogSearchScheduler, \ global __INITIALIZED__, backlogSearchScheduler, \
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \ showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \ properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
subtitlesFinderScheduler, traktCheckerScheduler, \ subtitlesFinderScheduler, traktCheckerScheduler, \
@ -1185,13 +1176,6 @@ def halt():
# abort all the threads # abort all the threads
maintenanceScheduler.abort = True
logger.log(u"Waiting for the MAINTENANCE scheduler thread to exit")
try:
maintenanceScheduler.thread.join(10)
except:
pass
dailySearchScheduler.abort = True dailySearchScheduler.abort = True
logger.log(u"Waiting for the DAILYSEARCH thread to exit") logger.log(u"Waiting for the DAILYSEARCH thread to exit")
try: try:

View File

@ -1,53 +0,0 @@
# Author: Nic Wolfe <nic@wolfeden.ca>
# URL: http://code.google.com/p/sickbeard/
#
# This file is part of SickRage.
#
# SickRage is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SickRage is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
from __future__ import with_statement
import threading
import sickbeard
from sickbeard import scene_exceptions
from sickbeard import failed_history
from sickbeard import network_timezones
from sickbeard import name_cache
class Maintenance():
def __init__(self):
self.lock = threading.Lock()
self.amActive = False
def run(self, force=False):
self.amActive = True
# clear internal name cache
name_cache.clearCache()
# get and update scene exceptions lists
scene_exceptions.retrieve_exceptions()
# build internal name cache for searches and parsing
name_cache.buildNameCache()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
self.amActive = False

View File

@ -96,7 +96,10 @@ def buildNameCache():
# clear internal name cache # clear internal name cache
clearCache() clearCache()
logger.log(u"Updating internal name cache", logger.MESSAGE) # update scene exception names
sickbeard.scene_exceptions.retrieve_exceptions()
logger.log(u"Building internal name cache", logger.MESSAGE)
cacheDB = db.DBConnection('cache.db') cacheDB = db.DBConnection('cache.db')
cache_results = cacheDB.select("SELECT * FROM scene_names") cache_results = cacheDB.select("SELECT * FROM scene_names")
@ -111,5 +114,4 @@ def buildNameCache():
for name in sickbeard.scene_exceptions.get_scene_exceptions(show.indexerid, season=curSeason): for name in sickbeard.scene_exceptions.get_scene_exceptions(show.indexerid, season=curSeason):
nameCache[sickbeard.helpers.full_sanitizeSceneName(name)] = show.indexerid nameCache[sickbeard.helpers.full_sanitizeSceneName(name)] = show.indexerid
logger.log(u"Updated internal name cache", logger.MESSAGE)
logger.log(u"Internal name cache set to: " + str(nameCache), logger.DEBUG) logger.log(u"Internal name cache set to: " + str(nameCache), logger.DEBUG)

View File

@ -123,8 +123,8 @@ class NameParser(object):
if not self.showObj and not self.naming_pattern: if not self.showObj and not self.naming_pattern:
# Regex pattern to return the Show / Series Name regardless of the file pattern tossed at it, matched 53 show name examples from regexes.py # Regex pattern to return the Show / Series Name regardless of the file pattern tossed at it, matched 53 show name examples from regexes.py
show_patterns = [ show_patterns = [
'''^(?P<show_name>.*?)\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))''', '''^(?P<show_name>.*)\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))''',
'''^((\[.*?\])|(\d+[\.-]))*[ _\.]*(?P<show_name>.*?)(([ ._-]+\d+)|([ ._-]+s\d{2})).*''' '''^((\[.*?\])|(\d+[\.-]))*[ _\.]*(?P<show_name>.*)(([ ._-]+\d+)|([ ._-]+s\d{2})).*'''
] ]
# find show object # find show object

View File

@ -43,9 +43,6 @@ class SearchQueue(generic_queue.GenericQueue):
generic_queue.GenericQueue.__init__(self) generic_queue.GenericQueue.__init__(self)
self.queue_name = "SEARCHQUEUE" self.queue_name = "SEARCHQUEUE"
def __del__(self):
pass
def is_in_queue(self, show, segment): def is_in_queue(self, show, segment):
for cur_item in self.queue: for cur_item in self.queue:
if isinstance(cur_item, BacklogQueueItem) and cur_item.show == show and cur_item.segment == segment: if isinstance(cur_item, BacklogQueueItem) and cur_item.show == show and cur_item.segment == segment:
@ -77,17 +74,20 @@ class SearchQueue(generic_queue.GenericQueue):
def add_item(self, item): def add_item(self, item):
if isinstance(item, DailySearchQueueItem) and not self.is_in_queue(item.show, item.segment): if isinstance(item, DailySearchQueueItem) and not self.is_in_queue(item.show, item.segment):
sickbeard.name_cache.buildNameCache()
generic_queue.GenericQueue.add_item(self, item) generic_queue.GenericQueue.add_item(self, item)
elif isinstance(item, BacklogQueueItem) and not self.is_in_queue(item.show, item.segment): elif isinstance(item, BacklogQueueItem) and not self.is_in_queue(item.show, item.segment):
sickbeard.name_cache.buildNameCache()
generic_queue.GenericQueue.add_item(self, item) generic_queue.GenericQueue.add_item(self, item)
elif isinstance(item, ManualSearchQueueItem) and not self.is_in_queue(item.show, item.segment): elif isinstance(item, ManualSearchQueueItem) and not self.is_in_queue(item.show, item.segment):
sickbeard.name_cache.buildNameCache()
generic_queue.GenericQueue.add_item(self, item) generic_queue.GenericQueue.add_item(self, item)
elif isinstance(item, FailedQueueItem) and not self.is_in_queue(item.show, item.segment): elif isinstance(item, FailedQueueItem) and not self.is_in_queue(item.show, item.segment):
sickbeard.name_cache.buildNameCache()
generic_queue.GenericQueue.add_item(self, item) generic_queue.GenericQueue.add_item(self, item)
else: else:
logger.log(u"Not adding item, it's already in the queue", logger.DEBUG) logger.log(u"Not adding item, it's already in the queue", logger.DEBUG)
class DailySearchQueueItem(generic_queue.QueueItem): class DailySearchQueueItem(generic_queue.QueueItem):
def __init__(self, show, segment): def __init__(self, show, segment):
generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH) generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH)

View File

@ -37,6 +37,13 @@ class ShowUpdater():
update_datetime = datetime.datetime.now() update_datetime = datetime.datetime.now()
update_date = update_datetime.date() update_date = update_datetime.date()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
logger.log(u"Doing full update on all shows") logger.log(u"Doing full update on all shows")
# clean out cache directory, remove everything > 12 hours old # clean out cache directory, remove everything > 12 hours old