summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2014-12-22 07:23:14 -0500
committerBrian Coca <bcoca@ansible.com>2014-12-22 07:23:14 -0500
commitcefe0974d90957900de6f86ca8023ca80ebdaabc (patch)
tree020d37be04fea49aada9c6475ec570052e82f6fd
parenta55c6625d4771c44017fce1d487b38749b12b381 (diff)
parente0f72d58610aeea198195851292d6f561aad9606 (diff)
downloadansible-cefe0974d90957900de6f86ca8023ca80ebdaabc.tar.gz
Merge pull request #9870 from bcoca/jsonfile_fixes
cache json fixes
-rw-r--r--lib/ansible/cache/jsonfile.py5
-rw-r--r--lib/ansible/cache/redis.py4
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/ansible/cache/jsonfile.py b/lib/ansible/cache/jsonfile.py
index ca18974d3c..a3768209bc 100644
--- a/lib/ansible/cache/jsonfile.py
+++ b/lib/ansible/cache/jsonfile.py
@@ -17,14 +17,12 @@
import os
import time
-import json
import errno
from ansible import constants as C
from ansible import utils
from ansible.cache.base import BaseCacheModule
-
class CacheModule(BaseCacheModule):
"""
A caching module backed by json files.
@@ -70,12 +68,11 @@ class CacheModule(BaseCacheModule):
cachefile = "%s/%s" % (self._cache_dir, key)
try:
- #TODO: check if valid keys can have invalid FS chars, base32?
f = open(cachefile, 'w')
except (OSError,IOError), e:
utils.warning("error while trying to read %s : %s" % (cachefile, str(e)))
else:
- json.dump(value, f, ensure_ascii=False)
+ f.write(utils.jsonify(value))
finally:
f.close()
diff --git a/lib/ansible/cache/redis.py b/lib/ansible/cache/redis.py
index c55b74469d..776c6c7f80 100644
--- a/lib/ansible/cache/redis.py
+++ b/lib/ansible/cache/redis.py
@@ -20,9 +20,9 @@ import collections
# FIXME: can we store these as something else before we ship it?
import sys
import time
-import json
from ansible import constants as C
+from ansible.utils import jsonify
from ansible.cache.base import BaseCacheModule
try:
@@ -65,7 +65,7 @@ class CacheModule(BaseCacheModule):
return json.loads(value)
def set(self, key, value):
- value2 = json.dumps(value)
+ value2 = jsonify(value)
if self._timeout > 0: # a timeout of 0 is handled as meaning 'never expire'
self._cache.setex(self._make_key(key), int(self._timeout), value2)
else: