diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index ecf0fe29..bb81599d 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -471,13 +471,11 @@ class Tvdb: if cache is True: self.config['cache_enabled'] = True self.config['cache_location'] = self._getTempDir() - self.sess = CacheControl(cache=caches.FileCache(self.config['cache_location'])) elif cache is False: self.config['cache_enabled'] = False elif isinstance(cache, basestring): self.config['cache_enabled'] = True self.config['cache_location'] = cache - self.sess = CacheControl(cache=caches.FileCache(self.config['cache_location'])) else: raise ValueError("Invalid value for Cache %r (type was %s)" % (cache, type(cache))) @@ -565,14 +563,15 @@ class Tvdb: # get response from TVDB if self.config['cache_enabled']: + session = CacheControl(cache=caches.FileCache(self.config['cache_location'])) if self.config['proxy']: log().debug("Using proxy for URL: %s" % url) - self.sess.proxies = { + session.proxies = { "http": self.config['proxy'], "https": self.config['proxy'], } - resp = self.sess.get(url, cache_auto=True, params=params) + resp = session.get(url, cache_auto=True, params=params) else: resp = requests.get(url, params=params) except requests.exceptions.HTTPError, e: @@ -630,7 +629,7 @@ class Tvdb: """ try: src = self._loadUrl(url, params=params, language=language) - src = [src[item] for item in src][0] + src = [src[item] for item in src][0] if src else [] except: errormsg = "There was an error with the XML retrieved from thetvdb.com:" diff --git a/lib/tvrage_api/tvrage_api.py b/lib/tvrage_api/tvrage_api.py index 86194f86..734b5ab3 100644 --- a/lib/tvrage_api/tvrage_api.py +++ b/lib/tvrage_api/tvrage_api.py @@ -305,7 +305,6 @@ class TVRage: self.shows = ShowContainer() # Holds all Show classes self.corrections = {} # Holds show-name to show_id mapping - self.sess = requests.session() # HTTP Session self.config = {} @@ -323,13 +322,11 @@ class TVRage: if cache is True: self.config['cache_enabled'] = True self.config['cache_location'] = self._getTempDir() - self.sess = CacheControl(cache=caches.FileCache(self.config['cache_location'])) elif cache is False: self.config['cache_enabled'] = False elif isinstance(cache, basestring): self.config['cache_enabled'] = True self.config['cache_location'] = cache - self.sess = CacheControl(cache=caches.FileCache(self.config['cache_location'])) else: raise ValueError("Invalid value for Cache %r (type was %s)" % (cache, type(cache))) @@ -396,6 +393,7 @@ class TVRage: except ImportError: return os.path.join(tempfile.gettempdir(), "tvrage_api") + return os.path.join(tempfile.gettempdir(), "tvrage_api-%s" % (uid)) #@retry(tvrage_error) @@ -405,14 +403,15 @@ class TVRage: # get response from TVRage if self.config['cache_enabled']: + session = CacheControl(cache=caches.FileCache(self.config['cache_location'])) if self.config['proxy']: log().debug("Using proxy for URL: %s" % url) - self.sess.proxies = { + session.proxies = { "http": self.config['proxy'], "https": self.config['proxy'], } - resp = self.sess.get(url.strip(), cache_auto=True, params=params) + resp = session.get(url.strip(), cache_auto=True, params=params) else: resp = requests.get(url.strip(), params=params) @@ -488,7 +487,7 @@ class TVRage: try: src = self._loadUrl(url, params) - src = [src[item] for item in src][0] + src = [src[item] for item in src][0] if src else [] except: errormsg = "There was an error with the XML retrieved from tvrage.com" diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index 1bd4da29..a276961b 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -200,10 +200,11 @@ class WindowsUpdateManager(UpdateManager): sickbeard.NEWEST_VERSION_STRING = newest_text - def update(self, branch='windows_binaries'): + def update(self, branch=None): # set branch version - self.branch = branch + if branch: + self.branch = branch zip_download_url = self._find_newest_version(True) logger.log(u"new_link: " + repr(zip_download_url), logger.DEBUG) @@ -505,14 +506,15 @@ class GitUpdateManager(UpdateManager): return False - def update(self, branch=sickbeard.version.SICKBEARD_VERSION): + def update(self, branch=None): """ Calls git pull origin in order to update SickRage. Returns a bool depending on the call's success. """ # set branch version - self.branch = branch + if branch: + self.branch = branch if self.branch == sickbeard.version.SICKBEARD_VERSION: output, err, exit_status = self._run_git(self._git_path, 'pull -f origin ' + self.branch) # @UnusedVariable @@ -645,13 +647,14 @@ class SourceUpdateManager(UpdateManager): sickbeard.NEWEST_VERSION_STRING = newest_text - def update(self, branch=sickbeard.version.SICKBEARD_VERSION): + def update(self, branch=None): """ Downloads the latest source tarball from github and installs it over the existing version. """ # set branch version - self.branch = branch + if branch: + self.branch = branch base_url = 'http://github.com/' + self.github_repo_user + '/' + self.github_repo tar_download_url = base_url + '/tarball/' + self.branch