1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-04 07:02:26 -05:00

Added in context to aid in garbage cleanup to help reduce memory usage.

This commit is contained in:
echel0n 2014-06-30 10:48:18 -07:00
parent 2e8c8a262f
commit a1cef0b958
44 changed files with 240 additions and 18 deletions

View File

@ -42,3 +42,6 @@ class PostProcesser():
return
processTV.processDir(sickbeard.TV_DOWNLOAD_DIR)
def __del__(self):
pass

View File

@ -35,6 +35,9 @@ class BlackAndWhiteList(object):
self.show_id = show_id
self.refresh()
def __del__(self):
pass
def refresh(self):
logger.log(u"Building black and white list for " + str(self.show_id), logger.DEBUG)

View File

@ -36,6 +36,9 @@ class DailySearcher():
self.amActive = False
def __del__(self):
pass
def run(self, force=False):
self.amActive = True

View File

@ -44,6 +44,9 @@ class FailedProcessor(object):
self.log = ""
def __del__(self):
pass
def process(self):
self._log(u"Failed download detected: (" + str(self.nzb_name) + ", " + str(self.dir_name) + ")")

View File

@ -43,6 +43,9 @@ class GenericQueue(object):
self.lock = threading.Lock()
def __del__(self):
pass
def pause(self):
logger.log(u"Pausing queue")
self.min_priority = 999999999999
@ -116,6 +119,9 @@ class QueueItem:
self.added = None
def __del__(self):
pass
def get_thread_name(self):
if self.thread_name:
return self.thread_name

View File

@ -33,6 +33,9 @@ class ImageCache:
def __init__(self):
pass
def __del__(self):
pass
def _cache_dir(self):
"""
Builds up the full path to the image cache directory

View File

@ -25,6 +25,9 @@ class indexerApi(object):
def __init__(self, indexerID=None):
self.indexerID = int(indexerID) if indexerID else None
def __del__(self):
pass
def indexer(self, *args, **kwargs):
if self.indexerID:
return indexerConfig[self.indexerID]['module'](*args, **kwargs)

View File

@ -67,6 +67,9 @@ class SBRotatingLogHandler(object):
self.console_logging = False
self.log_lock = threading.Lock()
def __del__(self):
pass
def close_log(self, handler=None):
if not handler:
handler = self.cur_handler
@ -302,6 +305,9 @@ class DispatchingFormatter:
self._formatters = formatters
self._default_formatter = default_formatter
def __del__(self):
pass
def format(self, record):
formatter = self._formatters.get(record.name, self._default_formatter)
return formatter.format(record)

View File

@ -31,6 +31,9 @@ class Maintenance():
self.amActive = False
def __del__(self):
pass
def run(self, force=False):
self.amActive = True

View File

@ -45,6 +45,9 @@ class NameParser(object):
self.convert = convert
self.naming_pattern = naming_pattern
def __del__(self):
pass
def clean_series_name(self, series_name):
"""Cleans up series name by removing any . and _
characters, along with any trailing hyphens.
@ -443,6 +446,9 @@ class ParseResult(object):
self.show = show
self.score = score
def __del__(self):
pass
def __eq__(self, other):
if not other:
return False
@ -618,6 +624,8 @@ class NameParserCache(object):
logger.log("Using cached parse result for: " + name, logger.DEBUG)
return self._previous_parsed[name]
def __del__(self):
pass
name_parser_cache = NameParserCache()

View File

@ -96,6 +96,8 @@ class PostProcessor(object):
self.log = ''
def __del__(self):
pass
def _log(self, message, level=logger.MESSAGE):
"""

View File

@ -40,6 +40,9 @@ class ProperFinder():
def __init__(self):
self.amActive = False
def __del__(self):
pass
def run(self, force=False):
if not sickbeard.DOWNLOAD_PROPERS:

View File

@ -49,6 +49,9 @@ class BTNProvider(generic.TorrentProvider):
self.url = "http://api.btnapps.net"
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -315,6 +318,9 @@ class BTNCache(tvcache.TVCache):
# At least 15 minutes between queries
self.minTime = 15
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -47,6 +47,9 @@ class EZRSSProvider(generic.TorrentProvider):
self.url = 'https://www.ezrss.it/'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -178,6 +181,9 @@ class EZRSSCache(tvcache.TVCache):
# only poll EZRSS every 15 minutes max
self.minTime = 15
def __del__(self):
pass
def _getRSSData(self):
rss_url = self.provider.url + 'feed/'

View File

@ -45,6 +45,9 @@ class Fanzub(generic.NZBProvider):
self.url = 'http://fanzub.com/'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -131,6 +134,8 @@ class FanzubCache(tvcache.TVCache):
# we get 100 post each call !
self.minTime = 20
def __del__(self):
pass
def _getRSSData(self):

View File

@ -68,6 +68,9 @@ class GenericProvider:
self.session.headers.update({
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'})
def __del__(self):
pass
def getID(self):
return GenericProvider.makeID(self.name)
@ -406,9 +409,14 @@ class NZBProvider(GenericProvider):
self.providerType = GenericProvider.NZB
def __del__(self):
pass
class TorrentProvider(GenericProvider):
def __init__(self, name):
GenericProvider.__init__(self, name)
self.providerType = GenericProvider.TORRENT
self.providerType = GenericProvider.TORRENT
def __del__(self):
pass

View File

@ -55,6 +55,9 @@ class HDBitsProvider(generic.TorrentProvider):
self.rss_url = 'http://hdbits.org/api/torrents'
self.download_url = 'http://hdbits.org/download.php?'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -214,6 +217,9 @@ class HDBitsCache(tvcache.TVCache):
# only poll HDBits every 15 minutes max
self.minTime = 15
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -73,6 +73,9 @@ class HDTorrentsProvider(generic.TorrentProvider):
self.cookies = None
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -351,6 +354,9 @@ class HDTorrentsCache(tvcache.TVCache):
# only poll HDTorrents every 10 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -65,6 +65,9 @@ class IPTorrentsProvider(generic.TorrentProvider):
self.categorie = 'l73=1&l78=1&l66=1&l65=1&l79=1&l5=1&l4=1'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -292,6 +295,9 @@ class IPTorrentsCache(tvcache.TVCache):
# Only poll IPTorrents every 10 minutes max
self.minTime = 10
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -68,6 +68,9 @@ class KATProvider(generic.TorrentProvider):
self.searchurl = self.url + 'usearch/%s/?field=seeders&sorder=desc' #order by seed
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -430,6 +433,9 @@ class KATCache(tvcache.TVCache):
# only poll ThePirateBay every 10 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -40,6 +40,9 @@ class NewzbinDownloader(urllib.FancyURLopener):
def __init__(self):
urllib.FancyURLopener.__init__(self)
def __del__(self):
pass
def http_error_default(self, url, fp, errcode, errmsg, headers):
# if newzbin is throttling us, wait seconds and try again
@ -73,6 +76,9 @@ class NewzbinProvider(generic.NZBProvider):
self.NEWZBIN_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S %Z'
def __del__(self):
pass
def isEnabled(self):
return sickbeard.NEWZBIN
@ -334,6 +340,9 @@ class NewzbinCache(tvcache.TVCache):
# only poll Newzbin every 10 mins max
self.minTime = 1
def __del__(self):
pass
def _getRSSData(self):
return self.provider._getRSSData()

View File

@ -69,6 +69,9 @@ class NewznabProvider(generic.NZBProvider):
self.default = False
def __del__(self):
pass
def configStr(self):
return self.name + '|' + self.url + '|' + self.key + '|' + self.catIDs + '|' + str(int(self.enabled)) + '|' + self.search_mode + '|' + str(int(self.search_fallback))
@ -292,6 +295,9 @@ class NewznabCache(tvcache.TVCache):
# only poll newznab providers every 15 minutes max
self.minTime = 15
def __del__(self):
pass
def _getRSSData(self):
params = {"t": "tvsearch",

View File

@ -71,6 +71,9 @@ class NextGenProvider(generic.TorrentProvider):
self.login_opener = None
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -341,6 +344,9 @@ class NextGenCache(tvcache.TVCache):
# Only poll NextGen every 10 minutes max
self.minTime = 10
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -45,6 +45,9 @@ class NyaaProvider(generic.TorrentProvider):
self.url = 'http://www.nyaa.se/'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -127,6 +130,8 @@ class NyaaCache(tvcache.TVCache):
# only poll NyaaTorrents every 15 minutes max
self.minTime = 15
def __del__(self):
pass
def _getRSSData(self):
params = {

View File

@ -49,6 +49,9 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
self.url = 'https://omgwtfnzbs.org/'
self.supportsBacklog = True
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -157,6 +160,9 @@ class OmgwtfnzbsCache(tvcache.TVCache):
tvcache.TVCache.__init__(self, provider)
self.minTime = 20
def __del__(self):
pass
def _getRSSData(self):
params = {'user': provider.username,
'api': provider.api_key,

View File

@ -67,6 +67,9 @@ class PublicHDProvider(generic.TorrentProvider):
self.categories = {'Season': ['23'], 'Episode': ['7', '14', '24'], 'RSS': ['7', '14', '23', '24']}
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -314,6 +317,9 @@ class PublicHDCache(tvcache.TVCache):
# only poll ThePirateBay every 10 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -52,6 +52,9 @@ class TorrentRssProvider(generic.TorrentProvider):
else:
self.cookies = ''
def __del__(self):
pass
def configStr(self):
return self.name + '|' + self.url + '|' + self.cookies + '|' + str(int(self.enabled)) + '|' + self.search_mode + '|' + str(int(self.search_fallback)) + '|' + str(int(self.backlog_only))
@ -170,6 +173,9 @@ class TorrentRssCache(tvcache.TVCache):
tvcache.TVCache.__init__(self, provider)
self.minTime = 15
def __del__(self):
pass
def _getRSSData(self):
logger.log(u"TorrentRssCache cache update URL: " + self.provider.url, logger.DEBUG)
if self.provider.cookies:

View File

@ -73,6 +73,9 @@ class SCCProvider(generic.TorrentProvider):
self.headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36'}
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -336,6 +339,9 @@ class SCCCache(tvcache.TVCache):
# only poll SCC every 10 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -66,6 +66,9 @@ class SpeedCDProvider(generic.TorrentProvider):
self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c49': 1}, 'RSS': {'c14': 1, 'c2': 1, 'c49': 1}}
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -276,6 +279,9 @@ class SpeedCDCache(tvcache.TVCache):
# only poll Speedcd every 20 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -67,6 +67,9 @@ class ThePirateBayProvider(generic.TorrentProvider):
self.re_title_url = '/torrent/(?P<id>\d+)/(?P<title>.*?)//1".+?(?P<url>magnet.*?)//1".+?(?P<seeders>\d+)</td>.+?(?P<leechers>\d+)</td>'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -409,6 +412,9 @@ class ThePirateBayCache(tvcache.TVCache):
# only poll ThePirateBay every 10 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days
@ -471,6 +477,9 @@ class ThePirateBayWebproxy:
'Hiload.org (NL)': 'http://hiload.org/',
}
def __del__(self):
pass
def isEnabled(self):
""" Return True if we Choose to call TPB via Proxy """
return self.enabled

View File

@ -72,6 +72,9 @@ class TorrentDayProvider(generic.TorrentProvider):
self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1},
'RSS': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1, 'c14': 1}}
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -300,6 +303,9 @@ class TorrentDayCache(tvcache.TVCache):
# Only poll IPTorrents every 10 minutes max
self.minTime = 10
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -67,6 +67,9 @@ class TorrentLeechProvider(generic.TorrentProvider):
self.categories = "2,26,27,32"
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -295,6 +298,9 @@ class TorrentLeechCache(tvcache.TVCache):
# only poll TorrentLeech every 20 minutes max
self.minTime = 20
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -47,6 +47,9 @@ class TvTorrentsProvider(generic.TorrentProvider):
self.url = 'http://www.tvtorrents.com/'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -86,6 +89,9 @@ class TvTorrentsCache(tvcache.TVCache):
# only poll TvTorrents every 15 minutes max
self.minTime = 15
def __del__(self):
pass
def _getRSSData(self):
# These will be ignored on the serverside.
ignore_regex = "all.month|month.of|season[\s\d]*complete"

View File

@ -31,6 +31,9 @@ class WombleProvider(generic.NZBProvider):
self.cache = WombleCache(self)
self.url = 'http://newshost.co.za/'
def __del__(self):
pass
def isEnabled(self):
return self.enabled
@ -41,6 +44,9 @@ class WombleCache(tvcache.TVCache):
# only poll Womble's Index every 15 minutes max
self.minTime = 15
def __del__(self):
pass
def updateCache(self):
# delete anything older then 7 days

View File

@ -23,23 +23,14 @@ class RSSFeeds:
logger.log(u"RSS error: " + ex(e), logger.ERROR)
raise
def __enter__(self):
return self
def __exit__(self, type, value, tb):
self.fc = None
def __del__(self):
self.fs.close()
def clearCache(self, age=None):
if not self.fc:
return
self.fc.purge(age)
def getRSSFeed(self, url, post_data=None, request_headers=None):
if not self.fc:
return
with feed_lock:
self.fc.purge(age)
def getFeed(self, url, post_data=None, request_headers=None):
with feed_lock:
parsed = list(urlparse.urlparse(url))
parsed[2] = re.sub("/{2,}", "/", parsed[2]) # replace two or more / with one
@ -59,4 +50,4 @@ class RSSFeeds:
logger.log(u"No RSS items found using URL: " + url, logger.WARNING)
return
return feed
return feed

View File

@ -44,6 +44,9 @@ class Scheduler:
self.abort = False
self.force = False
def __del__(self):
pass
def initThread(self):
if self.thread == None or not self.thread.isAlive():
self.thread = threading.Thread(None, self.runAction, self.threadName)

View File

@ -40,6 +40,8 @@ class BacklogSearchScheduler(scheduler.Scheduler):
else:
return datetime.date.fromordinal(self.action._lastBacklog + self.action.cycleTime)
def __del__(self):
pass
class BacklogSearcher:
def __init__(self):
@ -53,6 +55,9 @@ class BacklogSearcher:
self._resetPI()
def __del__(self):
pass
def _resetPI(self):
self.percentDone = 0
self.currentSearchInfo = {'title': 'Initializing'}

View File

@ -43,6 +43,9 @@ class SearchQueue(generic_queue.GenericQueue):
generic_queue.GenericQueue.__init__(self)
self.queue_name = "SEARCHQUEUE"
def __del__(self):
pass
def is_in_queue(self, show, segment):
for cur_item in self.queue:
if isinstance(cur_item, BacklogQueueItem) and cur_item.show == show and cur_item.segment == segment:
@ -93,6 +96,9 @@ class DailySearchQueueItem(generic_queue.QueueItem):
self.show = show
self.segment = segment
def __del__(self):
pass
def execute(self):
generic_queue.QueueItem.execute(self)
@ -125,6 +131,9 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
self.show = show
self.segment = segment
def __del__(self):
pass
def execute(self):
generic_queue.QueueItem.execute(self)
@ -168,6 +177,9 @@ class BacklogQueueItem(generic_queue.QueueItem):
self.show = show
self.segment = segment
def __del__(self):
pass
def execute(self):
generic_queue.QueueItem.execute(self)
@ -211,6 +223,9 @@ class FailedQueueItem(generic_queue.QueueItem):
self.segment = segment
self.success = None
def __del__(self):
pass
def execute(self):
generic_queue.QueueItem.execute(self)

View File

@ -103,3 +103,6 @@ class ShowUpdater():
ui.ProgressIndicators.setIndicator('dailyUpdate', ui.QueueProgressIndicator("Daily Update", piList))
logger.log(u"Completed full update on all shows")
def __del__(self):
pass

View File

@ -33,6 +33,9 @@ class TraktChecker():
self.todoWanted = []
self.todoBacklog = []
def __del__(self):
pass
def run(self, force=False):
# add shows from trakt.tv watchlist
if sickbeard.TRAKT_USE_WATCHLIST:

View File

@ -103,6 +103,9 @@ class TVShow(object):
self.loadFromDB()
def __del__(self):
pass
name = property(lambda self: self._name, dirty_setter("_name"))
indexerid = property(lambda self: self._indexerid, dirty_setter("_indexerid"))
indexer = property(lambda self: self._indexer, dirty_setter("_indexer"))
@ -1348,6 +1351,9 @@ class TVEpisode(object):
self.checkForMetaFiles()
def __del__(self):
pass
name = property(lambda self: self._name, dirty_setter("_name"))
season = property(lambda self: self._season, dirty_setter("_season"))
episode = property(lambda self: self._episode, dirty_setter("_episode"))

View File

@ -68,6 +68,8 @@ class CacheDBConnection(db.DBConnection):
if str(e) != "table lastUpdate already exists":
raise
def __del__(self):
pass
class TVCache():
def __init__(self, provider):
@ -76,6 +78,9 @@ class TVCache():
self.providerID = self.provider.getID()
self.minTime = 10
def __del__(self):
pass
def _getDB(self):
return CacheDBConnection(self.providerID)
@ -134,9 +139,7 @@ class TVCache():
return []
def getRSSFeed(self, url, post_data=None, request_headers=None):
with RSSFeeds(self.providerID) as feed:
data = feed.getRSSFeed(url, post_data, request_headers)
return data
return RSSFeeds(self.providerID).getFeed(url, post_data, request_headers)
def _translateTitle(self, title):
return title.replace(' ', '.')

View File

@ -30,6 +30,9 @@ class Notifications(object):
self._messages = []
self._errors = []
def __del__(self):
pass
def message(self, title, message=''):
"""
Add a regular notification to the queue
@ -89,6 +92,9 @@ class Notification(object):
else:
self._timeout = datetime.timedelta(minutes=1)
def __del__(self):
pass
def is_new(self, remote_ip='127.0.0.1'):
"""
Returns True if the notification hasn't been displayed to the current client (aka IP address).

View File

@ -53,6 +53,9 @@ class CheckVersion():
else:
self.updater = None
def __del__(self):
pass
def run(self, force=False):
if self.check_for_new_version():
if sickbeard.AUTO_UPDATE: