parent
5347db2952
commit
ddec06ccfe
2 changed files with 18 additions and 2 deletions
|
@ -70,14 +70,21 @@ from itertools import imap, repeat
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
# Detect the python-json library which is incompatible
|
||||||
|
# Look for simplejson if that's the case
|
||||||
|
try:
|
||||||
|
if not isinstance(json.loads, types.FunctionType) or not isinstance(json.dumps, types.FunctionType):
|
||||||
|
raise ImportError
|
||||||
|
except AttributeError:
|
||||||
|
raise ImportError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.stderr.write('Error: ansible requires a json module, none found!')
|
print('{"msg": "Error: ansible requires the stdlib json or simplejson module, neither was found!", "failed": true}')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
sys.stderr.write('SyntaxError: probably due to json and python being for different versions')
|
print('{"msg": "SyntaxError: probably due to installed simplejson being for a different python version", "failed": true}')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
HAVE_SELINUX=False
|
HAVE_SELINUX=False
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import stat
|
import stat
|
||||||
import array
|
import array
|
||||||
import errno
|
import errno
|
||||||
|
@ -43,9 +44,17 @@ except ImportError:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
# Detect python-json which is incompatible and fallback to simplejson in
|
||||||
|
# that case
|
||||||
|
try:
|
||||||
|
json.loads
|
||||||
|
json.dumps
|
||||||
|
except AttributeError:
|
||||||
|
raise ImportError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# timeout function to make sure some fact gathering
|
# timeout function to make sure some fact gathering
|
||||||
# steps do not exceed a time limit
|
# steps do not exceed a time limit
|
||||||
|
|
Loading…
Reference in a new issue