Update for modules which import json.

Some do not use the json module directly so don't need import json.
Some needed to fallback to simplejson with no traceback if neither was installed

Fixes #1298
reviewable/pr18780/r1
Toshio Kuratomi 9 years ago
parent 39c3004337
commit d6af6f8477

@ -98,7 +98,6 @@ task:
sample: "TODO: include sample"
'''
try:
import json
import boto
import botocore
HAS_BOTO = True
@ -123,7 +122,7 @@ class EcsExecManager:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
except boto.exception.NoAuthHandlerFound, e:
self.module.fail_json(msg="Can't authorize connection - "+str(e))
module.fail_json(msg="Can't authorize connection - "+str(e))
def list_tasks(self, cluster_name, service_name, status):
response = self.ecs.list_tasks(

@ -95,7 +95,6 @@ taskdefinition:
type: dict inputs plus revision, status, taskDefinitionArn
'''
try:
import json
import boto
import botocore
HAS_BOTO = True
@ -120,7 +119,7 @@ class EcsTaskManager:
module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")
self.ecs = boto3_conn(module, conn_type='client', resource='ecs', region=region, endpoint=ec2_url, **aws_connect_kwargs)
except boto.exception.NoAuthHandlerFound, e:
self.module.fail_json(msg="Can't authorize connection - "+str(e))
module.fail_json(msg="Can't authorize connection - "+str(e))
def describe_task(self, task_name):
try:

@ -160,7 +160,6 @@ EXAMPLES = '''
'''
try:
import json
import boto
import botocore
HAS_BOTO = True

@ -130,7 +130,6 @@ EXAMPLES = '''
'''
import time
import json
import xmltodict
VALID_RULE_KEYS = ['rule_type', 'original_ip', 'original_port',

@ -190,11 +190,6 @@ EXAMPLES = '''
import sys
try:
import json
except ImportError:
import simplejson as json
try:
import consul
from requests.exceptions import ConnectionError

@ -122,11 +122,6 @@ EXAMPLES = '''
import sys
try:
import json
except ImportError:
import simplejson as json
try:
import consul
from requests.exceptions import ConnectionError

@ -100,10 +100,15 @@ EXAMPLES = '''
import time
import socket
import sys
try:
import json
except ImportError:
import simplejson as json
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
def ring_check(module, riak_admin_bin):

@ -22,7 +22,15 @@ You should have received a copy of the GNU General Public License
along with Ansible. If not, see <http://www.gnu.org/licenses/>.
"""
import json
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
import datetime
import base64
import os

@ -174,16 +174,20 @@ EXAMPLES = '''
sensu_check: name=check_disk_capacity state=absent
'''
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
def sensu_check(module, path, name, state='present', backup=False):
changed = False
reasons = []
try:
import json
except ImportError:
import simplejson as json
stream = None
try:
try:

@ -92,10 +92,16 @@ EXAMPLES = '''
# ===========================================
# Stackdriver module specific support methods.
#
try:
import json
import json
except ImportError:
import simplejson as json
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
def send_deploy_event(module, key, revision_id, deployed_by='Ansible', deployed_to=None, repository=None):
"""Send a deploy event to Stackdriver"""

@ -64,7 +64,15 @@ EXAMPLES = '''
'''
import json
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
import urllib
import time

@ -59,7 +59,12 @@ ipify_public_ip:
try:
import json
except ImportError:
import simplejson as json
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
class IpifyFacts(object):

@ -128,7 +128,12 @@ import re
try:
import json
except ImportError:
import simplejson as json
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
def parse_out(string):
return re.sub("\s+", " ", string).strip()

@ -107,7 +107,12 @@ import os
try:
import json
except ImportError:
import simplejson as json
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
class Npm(object):
def __init__(self, module, **kwargs):

@ -109,7 +109,6 @@ EXAMPLES = '''
- pacman: name=baz state=absent force=yes
'''
import json
import shlex
import os
import re

@ -63,7 +63,6 @@ EXAMPLES = '''
'''
import json
import shlex
import os
import sys

@ -85,7 +85,6 @@ EXAMPLES = '''
'''
import json
import shlex
import os
import re

@ -58,7 +58,6 @@ EXAMPLES = '''
'''
import json
import shlex
import os
import sys

@ -73,7 +73,6 @@ EXAMPLES = '''
'''
import json
import shlex
import os
import sys

@ -18,7 +18,15 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import json
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
import base64
DOCUMENTATION = '''

@ -22,7 +22,12 @@ import stat
try:
import json
except ImportError:
import simplejson as json
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
DOCUMENTATION = '''
---

@ -160,7 +160,15 @@ EXAMPLES = """
issue={{issue.meta.key}} operation=transition status="Done"
"""
import json
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
# Let snippet from module_utils/basic.py return a proper error in this case
pass
import base64
def request(url, user, passwd, data=None, method=None):

Loading…
Cancel
Save