|
|
|
@ -45,7 +45,7 @@ class CacheModule(BaseCacheModule):
|
|
|
|
|
if not os.path.exists(self._cache_dir):
|
|
|
|
|
try:
|
|
|
|
|
os.makedirs(self._cache_dir)
|
|
|
|
|
except (OSError,IOError), e:
|
|
|
|
|
except (OSError,IOError) as e:
|
|
|
|
|
self._display.warning("error while trying to create cache dir %s : %s" % (self._cache_dir, str(e)))
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
@ -60,7 +60,7 @@ class CacheModule(BaseCacheModule):
|
|
|
|
|
cachefile = "%s/%s" % (self._cache_dir, key)
|
|
|
|
|
try:
|
|
|
|
|
f = codecs.open(cachefile, 'r', encoding='utf-8')
|
|
|
|
|
except (OSError,IOError), e:
|
|
|
|
|
except (OSError,IOError) as e:
|
|
|
|
|
self._display.warning("error while trying to read %s : %s" % (cachefile, str(e)))
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
@ -81,7 +81,7 @@ class CacheModule(BaseCacheModule):
|
|
|
|
|
cachefile = "%s/%s" % (self._cache_dir, key)
|
|
|
|
|
try:
|
|
|
|
|
f = codecs.open(cachefile, 'w', encoding='utf-8')
|
|
|
|
|
except (OSError,IOError), e:
|
|
|
|
|
except (OSError,IOError) as e:
|
|
|
|
|
self._display.warning("error while trying to write to %s : %s" % (cachefile, str(e)))
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
@ -94,7 +94,7 @@ class CacheModule(BaseCacheModule):
|
|
|
|
|
cachefile = "%s/%s" % (self._cache_dir, key)
|
|
|
|
|
try:
|
|
|
|
|
st = os.stat(cachefile)
|
|
|
|
|
except (OSError,IOError), e:
|
|
|
|
|
except (OSError,IOError) as e:
|
|
|
|
|
if e.errno == errno.ENOENT:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
@ -126,7 +126,7 @@ class CacheModule(BaseCacheModule):
|
|
|
|
|
try:
|
|
|
|
|
st = os.stat(cachefile)
|
|
|
|
|
return True
|
|
|
|
|
except (OSError,IOError), e:
|
|
|
|
|
except (OSError,IOError) as e:
|
|
|
|
|
if e.errno == errno.ENOENT:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
@ -137,7 +137,7 @@ class CacheModule(BaseCacheModule):
|
|
|
|
|
del self._cache[key]
|
|
|
|
|
try:
|
|
|
|
|
os.remove("%s/%s" % (self._cache_dir, key))
|
|
|
|
|
except (OSError,IOError), e:
|
|
|
|
|
except (OSError,IOError) as e:
|
|
|
|
|
pass #TODO: only pass on non existing?
|
|
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
|