@@ -46,7 +48,7 @@ class CacheModule(BaseCacheModule):
try:
os.makedirs(self._cache_dir)
except(OSError,IOError)ase:
self._display.warning("error while trying to create cache dir %s : %s"%(self._cache_dir,str(e)))
self._display.warning("error while trying to create cache dir %s : %s"%(self._cache_dir,to_bytes(e)))
returnNone
defget(self,key):
...
...
@@ -61,7 +63,7 @@ class CacheModule(BaseCacheModule):
try:
f=codecs.open(cachefile,'r',encoding='utf-8')
except(OSError,IOError)ase:
self._display.warning("error while trying to read %s : %s"%(cachefile,str(e)))
self._display.warning("error while trying to read %s : %s"%(cachefile,to_bytes(e)))
pass
else:
try:
...
...
@@ -69,7 +71,7 @@ class CacheModule(BaseCacheModule):
self._cache[key]=value
returnvalue
exceptValueErrorase:
self._display.warning("error while trying to read %s : %s. Most likely a corrupt file, so erasing and failing."%(cachefile,str(e)))
self._display.warning("error while trying to read %s : %s. Most likely a corrupt file, so erasing and failing."%(cachefile,to_bytes(e)))
self.delete(key)
raiseAnsibleError("The JSON cache file %s was corrupt, or did not otherwise contain valid JSON data. It has been removed, so you can re-run your command now."%cachefile)
finally:
...
...
@@ -83,7 +85,7 @@ class CacheModule(BaseCacheModule):
try:
f=codecs.open(cachefile,'w',encoding='utf-8')
except(OSError,IOError)ase:
self._display.warning("error while trying to write to %s : %s"%(cachefile,str(e)))
self._display.warning("error while trying to write to %s : %s"%(cachefile,to_bytes(e)))
pass
else:
f.write(jsonify(value))
...
...
@@ -99,7 +101,7 @@ class CacheModule(BaseCacheModule):
ife.errno==errno.ENOENT:
returnFalse
else:
self._display.warning("error while trying to stat %s : %s"%(cachefile,str(e)))
self._display.warning("error while trying to stat %s : %s"%(cachefile,to_bytes(e)))
pass
iftime.time()-st.st_mtime<=self._timeout:
...
...
@@ -131,7 +133,7 @@ class CacheModule(BaseCacheModule):
ife.errno==errno.ENOENT:
returnFalse
else:
self._display.warning("error while trying to stat %s : %s"%(cachefile,str(e)))
self._display.warning("error while trying to stat %s : %s"%(cachefile,to_bytes(e)))