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)