diff --git a/SickBeard.py b/SickBeard.py index 64876036..00d0a84d 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -67,7 +67,6 @@ from sickbeard.databases.mainDB import MIN_DB_VERSION from sickbeard.databases.mainDB import MAX_DB_VERSION from lib.configobj import ConfigObj -from daemon import Daemon signal.signal(signal.SIGINT, sickbeard.sig_handler) signal.signal(signal.SIGTERM, sickbeard.sig_handler) @@ -76,43 +75,7 @@ throwaway = datetime.datetime.strptime('20110101', '%Y%m%d') class SickRage(object): - def loadShowsFromDB(self): - """ - Populates the showList with shows from the database - """ - - logger.log(u"Loading initial show list") - - 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"])) - sickbeard.showList.append(curShow) - except Exception, e: - logger.log( - u"There was an error creating the show in " + sqlShow["location"] + ": " + str(e).decode('utf-8'), - logger.ERROR) - logger.log(traceback.format_exc(), logger.DEBUG) - - def restore(self, srcDir, dstDir): - try: - for file in os.listdir(srcDir): - srcFile = os.path.join(srcDir, file) - dstFile = os.path.join(dstDir, file) - bakFile = os.path.join(dstDir, file + '.bak') - shutil.move(dstFile, bakFile) - shutil.move(srcFile, dstFile) - - os.rmdir(srcDir) - return True - except: - return False - def __init__(self): - self.daemon = None self.webserver = None self.runAsDaemon = False self.CREATEPID = False @@ -288,8 +251,7 @@ class SickRage(object): sickbeard.initialize(consoleLogging=self.consoleLogging) if self.runAsDaemon: - self.daemon = Daemon(self.PIDFILE or os.path.join(sickbeard.DATA_DIR, 'sickbeard.pid')) - self.daemon.daemonize() + self.daemonize() # Get PID sickbeard.PID = os.getpid() @@ -361,6 +323,104 @@ class SickRage(object): while(sickbeard.started): time.sleep(1) + def daemonize(self): + """ + Fork off as a daemon + """ + + # pylint: disable=E1101 + # Make a non-session-leader child process + try: + pid = os.fork() # @UndefinedVariable - only available in UNIX + if pid != 0: + os._exit(0) + except OSError, e: + sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror)) + sys.exit(1) + + os.setsid() # @UndefinedVariable - only available in UNIX + + # Make sure I can read my own files and shut out others + prev = os.umask(0) + os.umask(prev and int('077', 8)) + + # Make the child a session-leader by detaching from the terminal + try: + pid = os.fork() # @UndefinedVariable - only available in UNIX + if pid != 0: + os._exit(0) + except OSError, e: + sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror)) + sys.exit(1) + + # Write pid + if self.CREATEPID: + pid = str(os.getpid()) + logger.log(u"Writing PID: " + pid + " to " + str(self.PIDFILE)) + try: + file(self.PIDFILE, 'w').write("%s\n" % pid) + except IOError, e: + logger.log_error_and_exit( + u"Unable to write PID file: " + self.PIDFILE + " Error: " + str(e.strerror) + " [" + str( + e.errno) + "]") + + # Redirect all output + sys.stdout.flush() + sys.stderr.flush() + + devnull = getattr(os, 'devnull', '/dev/null') + stdin = file(devnull, 'r') + stdout = file(devnull, 'a+') + stderr = file(devnull, 'a+') + os.dup2(stdin.fileno(), sys.stdin.fileno()) + os.dup2(stdout.fileno(), sys.stdout.fileno()) + os.dup2(stderr.fileno(), sys.stderr.fileno()) + + def remove_pid_file(self, PIDFILE): + try: + if os.path.exists(PIDFILE): + os.remove(PIDFILE) + + except (IOError, OSError): + return False + + return True + + def loadShowsFromDB(self): + """ + Populates the showList with shows from the database + """ + + logger.log(u"Loading initial show list") + + 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"])) + sickbeard.showList.append(curShow) + except Exception, e: + logger.log( + u"There was an error creating the show in " + sqlShow["location"] + ": " + str(e).decode('utf-8'), + logger.ERROR) + logger.log(traceback.format_exc(), logger.DEBUG) + + def restore(self, srcDir, dstDir): + try: + for file in os.listdir(srcDir): + srcFile = os.path.join(srcDir, file) + dstFile = os.path.join(dstDir, file) + bakFile = os.path.join(dstDir, file + '.bak') + shutil.move(dstFile, bakFile) + shutil.move(srcFile, dstFile) + + os.rmdir(srcDir) + return True + except: + return False + if __name__ == "__main__": if sys.hexversion >= 0x020600F0: freeze_support() @@ -379,8 +439,8 @@ if __name__ == "__main__": sr.webserver = None # if run as daemon delete the pidfile - if sr.runAsDaemon: - sr.daemon.delpid() + if sr.runAsDaemon and sr.CREATEPID: + sr.remove_pid_file(sr.PIDFILE) if not sickbeard.shutdown: install_type = sickbeard.versionCheckScheduler.action.install_type diff --git a/lib/daemon.py b/lib/daemon.py deleted file mode 100644 index 77c435b1..00000000 --- a/lib/daemon.py +++ /dev/null @@ -1,183 +0,0 @@ -# Core modules -import atexit -import os -import sys -import time -import signal - - -class Daemon(object): - """ - A generic daemon class. - - Usage: subclass the Daemon class and override the run() method - """ - def __init__(self, pidfile, stdin=os.devnull, - stdout=os.devnull, stderr=os.devnull, - home_dir='.', umask=022, verbose=1): - self.stdin = stdin - self.stdout = stdout - self.stderr = stderr - self.pidfile = pidfile - self.home_dir = home_dir - self.verbose = verbose - self.umask = umask - self.daemon_alive = True - - def daemonize(self): - """ - Do the UNIX double-fork magic, see Stevens' "Advanced - Programming in the UNIX Environment" for details (ISBN 0201563177) - http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 - """ - try: - pid = os.fork() - if pid > 0: - # Exit first parent - os._exit(0) - except OSError, e: - sys.stderr.write( - "fork #1 failed: %d (%s)\n" % (e.errno, e.strerror)) - sys.exit(1) - - # Decouple from parent environment - os.chdir(self.home_dir) - os.setsid() - os.umask(self.umask) - - # Do second fork - try: - pid = os.fork() - if pid > 0: - # Exit from second parent - os._exit(0) - except OSError, e: - sys.stderr.write( - "fork #2 failed: %d (%s)\n" % (e.errno, e.strerror)) - sys.exit(1) - - if sys.platform != 'darwin': # This block breaks on OS X - # Redirect standard file descriptors - sys.stdout.flush() - sys.stderr.flush() - si = file(self.stdin, 'r') - so = file(self.stdout, 'a+') - if self.stderr: - se = file(self.stderr, 'a+', 0) - else: - se = so - os.dup2(si.fileno(), sys.stdin.fileno()) - os.dup2(so.fileno(), sys.stdout.fileno()) - os.dup2(se.fileno(), sys.stderr.fileno()) - - if self.verbose >= 1: - print "Started" - - # Write pidfile - atexit.register( - self.delpid) # Make sure pid file is removed if we quit - pid = str(os.getpid()) - file(self.pidfile, 'w+').write("%s\n" % pid) - - def delpid(self): - os.remove(self.pidfile) - - def start(self, *args, **kwargs): - """ - Start the daemon - """ - - if self.verbose >= 1: - print "Starting..." - - # Check for a pidfile to see if the daemon already runs - try: - pf = file(self.pidfile, 'r') - pid = int(pf.read().strip()) - pf.close() - except IOError: - pid = None - except SystemExit: - pid = None - - if pid: - message = "pidfile %s already exists. Is it already running?\n" - sys.stderr.write(message % self.pidfile) - sys.exit(1) - - # Start the daemon - self.daemonize() - self.run(*args, **kwargs) - - def stop(self): - """ - Stop the daemon - """ - - if self.verbose >= 1: - print "Stopping..." - - # Get the pid from the pidfile - pid = self.get_pid() - - if not pid: - message = "pidfile %s does not exist. Not running?\n" - sys.stderr.write(message % self.pidfile) - - # Just to be sure. A ValueError might occur if the PID file is - # empty but does actually exist - if os.path.exists(self.pidfile): - os.remove(self.pidfile) - - return # Not an error in a restart - - # Try killing the daemon process - try: - i = 0 - while 1: - os.kill(pid, signal.SIGTERM) - time.sleep(0.1) - i = i + 1 - if i % 10 == 0: - os.kill(pid, signal.SIGHUP) - except OSError, err: - err = str(err) - if err.find("No such process") > 0: - if os.path.exists(self.pidfile): - os.remove(self.pidfile) - else: - print str(err) - sys.exit(1) - - if self.verbose >= 1: - print "Stopped" - - def restart(self): - """ - Restart the daemon - """ - self.stop() - self.start() - - def get_pid(self): - try: - pf = file(self.pidfile, 'r') - pid = int(pf.read().strip()) - pf.close() - except IOError: - pid = None - except SystemExit: - pid = None - return pid - - def is_running(self): - pid = self.get_pid() - print(pid) - return pid and os.path.exists('/proc/%d' % pid) - - def run(self): - """ - You should override this method when you subclass Daemon. - It will be called after the process has been - daemonized by start() or restart(). - """ \ No newline at end of file diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 46491d9a..218466b8 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -1274,17 +1274,6 @@ def halt(): __INITIALIZED__ = False started = False -def remove_pid_file(PIDFILE): - try: - if os.path.exists(PIDFILE): - os.remove(PIDFILE) - - except (IOError, OSError): - return False - - return True - - def sig_handler(signum=None, frame=None): if type(signum) != type(None): logger.log(u"Signal %i caught, saving and exiting..." % int(signum)) diff --git a/sickbeard/dailysearcher.py b/sickbeard/dailysearcher.py index 3559f371..967d3a47 100644 --- a/sickbeard/dailysearcher.py +++ b/sickbeard/dailysearcher.py @@ -36,9 +36,6 @@ class DailySearcher(): self.amActive = False - def __del__(self): - pass - def run(self, force=False): self.amActive = True diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index b1565dc2..055cf9f0 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -45,9 +45,6 @@ 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. @@ -446,9 +443,6 @@ class ParseResult(object): self.show = show self.score = score - def __del__(self): - pass - def __eq__(self, other): if not other: return False @@ -624,11 +618,7 @@ 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() - class InvalidNameException(Exception): "The given name is not valid" \ No newline at end of file diff --git a/sickbeard/providers/btn.py b/sickbeard/providers/btn.py index 1fd17210..5dca36ea 100644 --- a/sickbeard/providers/btn.py +++ b/sickbeard/providers/btn.py @@ -49,9 +49,6 @@ class BTNProvider(generic.TorrentProvider): self.url = "http://api.btnapps.net" - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -318,9 +315,6 @@ 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 @@ -349,7 +343,7 @@ class BTNCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/ezrss.py b/sickbeard/providers/ezrss.py index 4d594c5f..316f83e0 100644 --- a/sickbeard/providers/ezrss.py +++ b/sickbeard/providers/ezrss.py @@ -47,9 +47,6 @@ class EZRSSProvider(generic.TorrentProvider): self.url = 'https://www.ezrss.it/' - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -181,9 +178,6 @@ 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/' diff --git a/sickbeard/providers/fanzub.py b/sickbeard/providers/fanzub.py index 27c61bbb..0f58825c 100644 --- a/sickbeard/providers/fanzub.py +++ b/sickbeard/providers/fanzub.py @@ -45,9 +45,6 @@ class Fanzub(generic.NZBProvider): self.url = 'http://fanzub.com/' - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -134,9 +131,6 @@ class FanzubCache(tvcache.TVCache): # we get 100 post each call ! self.minTime = 20 - def __del__(self): - pass - def _getRSSData(self): params = {"cat": "anime".encode('utf-8'), diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 599d0233..a103364e 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -68,9 +68,6 @@ 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) @@ -409,14 +406,8 @@ 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 - - def __del__(self): - pass + self.providerType = GenericProvider.TORRENT \ No newline at end of file diff --git a/sickbeard/providers/hdbits.py b/sickbeard/providers/hdbits.py index 8821f0e2..6dd79c92 100644 --- a/sickbeard/providers/hdbits.py +++ b/sickbeard/providers/hdbits.py @@ -55,9 +55,6 @@ 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 @@ -217,9 +214,6 @@ 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 @@ -260,7 +254,7 @@ class HDBitsCache(tvcache.TVCache): if ci is not None: ql.append(ci) - time.sleep(.2) + if ql: myDB = self._getDB() diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index 9f9fa2e9..d17d1129 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -73,9 +73,6 @@ class HDTorrentsProvider(generic.TorrentProvider): self.cookies = None - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -354,9 +351,6 @@ 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 @@ -382,7 +376,7 @@ class HDTorrentsCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 39ec76d0..74fbe79a 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -65,9 +65,6 @@ 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 @@ -295,9 +292,6 @@ 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 @@ -323,7 +317,7 @@ class IPTorrentsCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 69080ca9..55278376 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -68,9 +68,6 @@ 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 @@ -433,9 +430,6 @@ 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 @@ -460,7 +454,7 @@ class KATCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/newzbin.py b/sickbeard/providers/newzbin.py index 685afc4b..bdf4b31e 100644 --- a/sickbeard/providers/newzbin.py +++ b/sickbeard/providers/newzbin.py @@ -40,9 +40,6 @@ 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 @@ -76,9 +73,6 @@ 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 @@ -340,9 +334,6 @@ 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() diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index b40fab34..a3ed5abe 100755 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -69,9 +69,6 @@ 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)) @@ -295,9 +292,6 @@ 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", @@ -347,7 +341,7 @@ class NewznabCache(tvcache.TVCache): if ci is not None: ql.append(ci) - time.sleep(.2) + if ql: myDB = self._getDB() diff --git a/sickbeard/providers/nextgen.py b/sickbeard/providers/nextgen.py index 79430263..96dc225d 100644 --- a/sickbeard/providers/nextgen.py +++ b/sickbeard/providers/nextgen.py @@ -71,9 +71,6 @@ class NextGenProvider(generic.TorrentProvider): self.login_opener = None - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -344,9 +341,6 @@ 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 @@ -372,7 +366,7 @@ class NextGenCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/nyaatorrents.py b/sickbeard/providers/nyaatorrents.py index 719feaee..23580ba9 100644 --- a/sickbeard/providers/nyaatorrents.py +++ b/sickbeard/providers/nyaatorrents.py @@ -45,9 +45,6 @@ class NyaaProvider(generic.TorrentProvider): self.url = 'http://www.nyaa.se/' - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -130,9 +127,6 @@ class NyaaCache(tvcache.TVCache): # only poll NyaaTorrents every 15 minutes max self.minTime = 15 - def __del__(self): - pass - def _getRSSData(self): params = { "page": 'rss', # Use RSS page diff --git a/sickbeard/providers/omgwtfnzbs.py b/sickbeard/providers/omgwtfnzbs.py index 7da7fdf3..d3fc8f1e 100644 --- a/sickbeard/providers/omgwtfnzbs.py +++ b/sickbeard/providers/omgwtfnzbs.py @@ -49,9 +49,6 @@ class OmgwtfnzbsProvider(generic.NZBProvider): self.url = 'https://omgwtfnzbs.org/' self.supportsBacklog = True - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -160,9 +157,6 @@ 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, diff --git a/sickbeard/providers/publichd.py b/sickbeard/providers/publichd.py index c280e43e..38aa9b24 100644 --- a/sickbeard/providers/publichd.py +++ b/sickbeard/providers/publichd.py @@ -67,9 +67,6 @@ 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 @@ -317,9 +314,6 @@ 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 @@ -345,7 +339,7 @@ class PublicHDCache(tvcache.TVCache): if ci is not None: ql.append(ci) - time.sleep(.2) + if ql: myDB = self._getDB() diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index 3aac4d8d..64d6e64d 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -52,9 +52,6 @@ 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)) @@ -173,9 +170,6 @@ 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: diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index b056e3e4..f8f71d73 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -73,9 +73,6 @@ 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 @@ -339,9 +336,6 @@ 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 @@ -367,7 +361,7 @@ class SCCCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index 0809620d..bb0c385b 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -66,9 +66,6 @@ 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 @@ -279,9 +276,6 @@ 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 @@ -307,7 +301,7 @@ class SpeedCDCache(tvcache.TVCache): if ci is not None: ql.append(ci) - time.sleep(.2) + if ql: myDB = self._getDB() diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 5e4c2653..7478e6da 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -67,9 +67,6 @@ class ThePirateBayProvider(generic.TorrentProvider): self.re_title_url = '/torrent/(?P\d+)/(?P.*?)//1".+?(?P<url>magnet.*?)//1".+?(?P<seeders>\d+)</td>.+?(?P<leechers>\d+)</td>' - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -410,9 +407,6 @@ 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 @@ -438,7 +432,7 @@ class ThePirateBayCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() @@ -477,9 +471,6 @@ 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 diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 3e7da459..bc19d1ee 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -72,9 +72,6 @@ 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 @@ -303,9 +300,6 @@ 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 @@ -331,7 +325,7 @@ class TorrentDayCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index 56e33227..90fece4d 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -67,9 +67,6 @@ class TorrentLeechProvider(generic.TorrentProvider): self.categories = "2,26,27,32" - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -298,9 +295,6 @@ 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 @@ -326,7 +320,7 @@ class TorrentLeechCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB() diff --git a/sickbeard/providers/tvtorrents.py b/sickbeard/providers/tvtorrents.py index c743dc30..fbbc17dd 100644 --- a/sickbeard/providers/tvtorrents.py +++ b/sickbeard/providers/tvtorrents.py @@ -47,9 +47,6 @@ class TvTorrentsProvider(generic.TorrentProvider): self.url = 'http://www.tvtorrents.com/' - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -89,9 +86,6 @@ 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" diff --git a/sickbeard/providers/womble.py b/sickbeard/providers/womble.py index 10f38e45..afc93741 100644 --- a/sickbeard/providers/womble.py +++ b/sickbeard/providers/womble.py @@ -32,9 +32,6 @@ class WombleProvider(generic.NZBProvider): self.cache = WombleCache(self) self.url = 'http://newshost.co.za/' - def __del__(self): - pass - def isEnabled(self): return self.enabled @@ -45,9 +42,6 @@ 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 @@ -74,7 +68,7 @@ class WombleCache(tvcache.TVCache): if ci is not None: cl.append(ci) - time.sleep(.2) + if cl: myDB = self._getDB()