From 5e507b384989b549295f736bc753f26f2e66c3f5 Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 30 Jun 2014 04:44:36 -0700 Subject: [PATCH] More memory reductions and cleanups --- sickbeard/blackandwhitelist.py | 1 - sickbeard/dailysearcher.py | 3 +++ sickbeard/network_timezones.py | 5 +++- sickbeard/postProcessor.py | 2 ++ sickbeard/providers/btn.py | 1 + sickbeard/providers/hdbits.py | 1 + sickbeard/providers/hdtorrents.py | 1 + sickbeard/providers/iptorrents.py | 1 + sickbeard/providers/kat.py | 1 + sickbeard/providers/newznab.py | 1 + sickbeard/providers/nextgen.py | 1 + sickbeard/providers/publichd.py | 1 + sickbeard/providers/scc.py | 1 + sickbeard/providers/speedcd.py | 1 + sickbeard/providers/thepiratebay.py | 1 + sickbeard/providers/torrentday.py | 1 + sickbeard/providers/torrentleech.py | 1 + sickbeard/providers/womble.py | 39 ++++++++++++++++------------- sickbeard/scene_exceptions.py | 5 +++- sickbeard/scene_numbering.py | 8 +++--- sickbeard/search.py | 1 + sickbeard/tv.py | 6 +++++ sickbeard/tvcache.py | 2 +- sickbeard/webapi.py | 1 + sickbeard/webserve.py | 1 + 25 files changed, 60 insertions(+), 27 deletions(-) diff --git a/sickbeard/blackandwhitelist.py b/sickbeard/blackandwhitelist.py index 6a56e4d6..70b35cd0 100644 --- a/sickbeard/blackandwhitelist.py +++ b/sickbeard/blackandwhitelist.py @@ -208,6 +208,5 @@ class BlackWhiteKeyword(object): self.range = range # "global" or a parser group self.value = values # a list of values may contain only one item (still a list) - class BlackWhitelistNoShowIDException(Exception): "No show_id was given" diff --git a/sickbeard/dailysearcher.py b/sickbeard/dailysearcher.py index 97470c17..a6d97f97 100644 --- a/sickbeard/dailysearcher.py +++ b/sickbeard/dailysearcher.py @@ -101,6 +101,7 @@ class DailySearcher(): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l if len(todaysEps): for show in todaysEps: @@ -114,4 +115,6 @@ class DailySearcher(): else: logger.log(u"Could not find any needed episodes to search for ...") + del todaysEps + self.amActive = False \ No newline at end of file diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index d8a243c5..64cf37ad 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -165,6 +165,7 @@ def update_network_dict(): pass myDB = db.DBConnection('cache.db') + # load current network timezones old_d = dict(myDB.select("SELECT * FROM network_timezones")) @@ -181,15 +182,17 @@ def update_network_dict(): ql.append(["INSERT INTO network_timezones (network_name, timezone) VALUES (?,?)", [cur_d, cur_t]]) if h_k: del old_d[cur_d] + # remove deleted records if len(old_d) > 0: L = list(va for va in old_d) ql.append(["DELETE FROM network_timezones WHERE network_name IN (" + ','.join(['?'] * len(L)) + ")", L]) + # change all network timezone infos at once (much faster) if ql: myDB.mass_action(ql) load_network_dict() - + del ql # load network timezones from db into dict def load_network_dict(): diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 311471a2..233c2fab 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -965,6 +965,7 @@ class PostProcessor(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l # find the destination folder try: @@ -1042,6 +1043,7 @@ class PostProcessor(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l # log it to history history.logDownload(ep_obj, self.file_path, new_ep_quality, self.release_group) diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index 71c69c48..0b1518b5 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -346,6 +346,7 @@ class BTNCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl else: raise AuthException( diff --git a/sickbeard/providers/hdbits.py b/sickbeard/providers/hdbits.py index ab5829c1..ee1ae26d 100644 --- a/sickbeard/providers/hdbits.py +++ b/sickbeard/providers/hdbits.py @@ -257,6 +257,7 @@ class HDBitsCache(tvcache.TVCache): if ql: myDB = self._getDB() myDB.mass_action(ql) + del ql else: raise exceptions.AuthException( diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index dce7b540..b506d794 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -379,6 +379,7 @@ class HDTorrentsCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 8dc1288d..76a80173 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -320,6 +320,7 @@ class IPTorrentsCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 95b14338..dbffb658 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -457,6 +457,7 @@ class KATCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index 4b2bddb0..59f0ca5a 100755 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -344,6 +344,7 @@ class NewznabCache(tvcache.TVCache): if ql: myDB = self._getDB() myDB.mass_action(ql) + del ql else: raise AuthException( diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index d8a3cda8..91bc9dc3 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -369,6 +369,7 @@ class NextGenCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/publichd.py b/sickbeard/providers/publichd.py index fdd737ec..3fae3429 100644 --- a/sickbeard/providers/publichd.py +++ b/sickbeard/providers/publichd.py @@ -342,6 +342,7 @@ class PublicHDCache(tvcache.TVCache): if ql: myDB = self._getDB() myDB.mass_action(ql) + del ql def _parseItem(self, item): diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index c38262b8..71eb2155 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -364,6 +364,7 @@ class SCCCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index d0aa2823..e238a8ea 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -304,6 +304,7 @@ class SpeedCDCache(tvcache.TVCache): if ql: myDB = self._getDB() myDB.mass_action(ql) + del ql def _parseItem(self, item): diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index af2e838c..336aedf8 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -437,6 +437,7 @@ class ThePirateBayCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 165408a8..6e4f07be 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -328,6 +328,7 @@ class TorrentDayCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index 33e1e8e6..d5ae7ab3 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -323,6 +323,7 @@ class TorrentLeechCache(tvcache.TVCache): if cl: myDB = self._getDB() myDB.mass_action(cl) + del cl def _parseItem(self, item): diff --git a/sickbeard/providers/womble.py b/sickbeard/providers/womble.py index 8dbfe9b7..173b4add 100644 --- a/sickbeard/providers/womble.py +++ b/sickbeard/providers/womble.py @@ -48,30 +48,33 @@ class WombleCache(tvcache.TVCache): self._clearCache() data = None + if not self.shouldUpdate(): - for url in [self.provider.url + 'rss/?sec=tv-sd&fr=false', self.provider.url + 'rss/?sec=tv-hd&fr=false']: - logger.log(u"Womble's Index cache update URL: " + url, logger.DEBUG) - data = self.getRSSFeed(url) + return - # As long as we got something from the provider we count it as an update - if not data: - return [] + cl = [] + for url in [self.provider.url + 'rss/?sec=tv-sd&fr=false', self.provider.url + 'rss/?sec=tv-hd&fr=false']: + logger.log(u"Womble's Index cache update URL: " + url, logger.DEBUG) + data = self.getRSSFeed(url) - # By now we know we've got data and no auth errors, all we need to do is put it in the database - cl = [] - for item in data.entries: + # As long as we got something from the provider we count it as an update + if not data: + return [] - ci = self._parseItem(item) - if ci is not None: - cl.append(ci) + # By now we know we've got data and no auth errors, all we need to do is put it in the database + for item in data.entries: + ci = self._parseItem(item) + if ci is not None: + cl.append(ci) - if cl: - myDB = self._getDB() - myDB.mass_action(cl) + if cl: + myDB = self._getDB() + myDB.mass_action(cl) + del cl - # set last updated - if data: - self.setLastUpdate() + # set last updated + if data: + self.setLastUpdate() def _checkAuth(self, data): return data != 'Invalid Link' diff --git a/sickbeard/scene_exceptions.py b/sickbeard/scene_exceptions.py index 13c34a09..75cbdac2 100644 --- a/sickbeard/scene_exceptions.py +++ b/sickbeard/scene_exceptions.py @@ -209,6 +209,10 @@ def retrieve_exceptions(): else: logger.log(u"No scene exceptions update needed") + # cleanup + del existing_exceptions + del exception_dict + def update_scene_exceptions(indexer_id, scene_exceptions): """ Given a indexer_id, and a list of all show scene exceptions, update the db. @@ -227,7 +231,6 @@ def update_scene_exceptions(indexer_id, scene_exceptions): def _retrieve_anidb_mainnames(): - anidb_mainNames = {} if shouldRefresh('anidb'): diff --git a/sickbeard/scene_numbering.py b/sickbeard/scene_numbering.py index 3fd9789e..60774ce6 100644 --- a/sickbeard/scene_numbering.py +++ b/sickbeard/scene_numbering.py @@ -528,10 +528,7 @@ def xem_refresh(indexer_id, indexer, force=False): if ql: myDB = db.DBConnection() myDB.mass_action(ql) - - # fix xem scene numbering issues - # fix_xem_numbering(indexer_id, indexer) - + del ql def fix_xem_numbering(indexer_id, indexer): """ @@ -694,4 +691,5 @@ def fix_xem_numbering(indexer_id, indexer): if ql: myDB = db.DBConnection() - myDB.mass_action(ql) \ No newline at end of file + myDB.mass_action(ql) + del ql \ No newline at end of file diff --git a/sickbeard/search.py b/sickbeard/search.py index 800dbf33..6bdc06b5 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -175,6 +175,7 @@ def snatchEpisode(result, endStatus=SNATCHED): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l return True diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 1cf9e35f..28a6c521 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -456,6 +456,7 @@ class TVShow(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l def loadEpisodesFromDB(self): @@ -577,6 +578,7 @@ class TVShow(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l # Done updating save last update date self.last_update_indexer = datetime.date.today().toordinal() @@ -747,6 +749,7 @@ class TVShow(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l # creating metafiles on the root should be good enough if sickbeard.USE_FAILED_DOWNLOADS and rootEp is not None: @@ -1002,6 +1005,7 @@ class TVShow(object): myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l # remove self from show list sickbeard.showList = [x for x in sickbeard.showList if int(x.indexerid) != self.indexerid] @@ -1076,6 +1080,7 @@ class TVShow(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l def airdateModifyStamp(self, ep_obj): """ @@ -2415,3 +2420,4 @@ class TVEpisode(object): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index ba6a59a7..74477c2f 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -129,7 +129,7 @@ class TVCache(): if cl: myDB = self._getDB() myDB.mass_action(cl) - + del cl else: raise AuthException( u"Your authentication credentials for " + self.provider.name + " are incorrect, check your config") diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index 9be9839a..f294981f 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1007,6 +1007,7 @@ class CMD_EpisodeSetStatus(ApiCall): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l extra_msg = "" if start_backlog: diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index d41f913c..755edd15 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3998,6 +3998,7 @@ class Home(MainHandler): if sql_l: myDB = db.DBConnection() myDB.mass_action(sql_l) + del sql_l if int(status) == WANTED: msg = "Backlog was automatically started for the following seasons of " + showObj.name + ":
"