Urlopen try,except fixes

This commit is contained in:
Ruud
2011-11-11 15:47:57 +01:00
parent 0420bdeec5
commit 668b95353f
19 changed files with 116 additions and 133 deletions
+9 -1
View File
@@ -160,12 +160,20 @@ class Plugin(object):
log.error("Something went wrong when finishing the plugin function. Could not find the 'is_running' key")
def getCache(self, cache_key):
def getCache(self, cache_key, url = None):
cache = Env.get('cache').get(cache_key)
if cache:
log.debug('Getting cache %s' % cache_key)
return cache
if url:
try:
data = self.urlopen(url)
self.setCache(cache_key, data)
return data
except:
pass
def setCache(self, cache_key, value, timeout = 300):
log.debug('Setting cache %s' % cache_key)
Env.get('cache').set(cache_key, value, timeout)
+3 -3
View File
@@ -34,9 +34,9 @@ class FileManager(Plugin):
def download(self, url = '', dest = None, overwrite = False):
file = self.urlopen(url)
if not file:
log.error('File is empty, don\'t download')
try:
file = self.urlopen(url)
except:
return False
if not dest: # to Cache
+5 -2
View File
@@ -261,7 +261,10 @@ class Searcher(Plugin):
nfo = self.getCache(cache_key)
if not nfo:
nfo = self.urlopen('http://www.srrdb.com/showfile.php?release=%s' % check_name)
self.setCache(cache_key, nfo)
try:
nfo = self.urlopen('http://www.srrdb.com/showfile.php?release=%s' % check_name)
self.setCache(cache_key, nfo)
except:
pass
return getImdb(nfo) == imdb_id