diff options
-rw-r--r-- | cloud/amazon/ecs_task.py | 3 | ||||
-rw-r--r-- | cloud/amazon/ecs_taskdefinition.py | 3 | ||||
-rw-r--r-- | cloud/amazon/route53_facts.py | 1 | ||||
-rw-r--r-- | cloud/vmware/vca_nat.py | 1 | ||||
-rw-r--r-- | clustering/consul.py | 5 | ||||
-rw-r--r-- | clustering/consul_kv.py | 5 | ||||
-rw-r--r-- | database/misc/riak.py | 7 | ||||
-rw-r--r-- | monitoring/boundary_meter.py | 10 | ||||
-rw-r--r-- | monitoring/sensu_check.py | 14 | ||||
-rw-r--r-- | monitoring/stackdriver.py | 10 | ||||
-rw-r--r-- | monitoring/uptimerobot.py | 10 | ||||
-rw-r--r-- | network/ipify_facts.py | 7 | ||||
-rw-r--r-- | packaging/language/composer.py | 7 | ||||
-rw-r--r-- | packaging/language/npm.py | 7 | ||||
-rw-r--r-- | packaging/os/pacman.py | 1 | ||||
-rw-r--r-- | packaging/os/pkgin.py | 1 | ||||
-rw-r--r-- | packaging/os/pkgng.py | 1 | ||||
-rw-r--r-- | packaging/os/portinstall.py | 1 | ||||
-rw-r--r-- | packaging/os/urpmi.py | 1 | ||||
-rw-r--r-- | source_control/github_hooks.py | 10 | ||||
-rw-r--r-- | system/puppet.py | 7 | ||||
-rw-r--r-- | web_infrastructure/jira.py | 10 |
22 files changed, 85 insertions, 37 deletions
diff --git a/cloud/amazon/ecs_task.py b/cloud/amazon/ecs_task.py index 000ce68b..c2bd7375 100644 --- a/cloud/amazon/ecs_task.py +++ b/cloud/amazon/ecs_task.py @@ -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( diff --git a/cloud/amazon/ecs_taskdefinition.py b/cloud/amazon/ecs_taskdefinition.py index 50205d66..6ad23a88 100644 --- a/cloud/amazon/ecs_taskdefinition.py +++ b/cloud/amazon/ecs_taskdefinition.py @@ -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: diff --git a/cloud/amazon/route53_facts.py b/cloud/amazon/route53_facts.py index d6081dba..40bcea73 100644 --- a/cloud/amazon/route53_facts.py +++ b/cloud/amazon/route53_facts.py @@ -160,7 +160,6 @@ EXAMPLES = ''' ''' try: - import json import boto import botocore HAS_BOTO = True diff --git a/cloud/vmware/vca_nat.py b/cloud/vmware/vca_nat.py index 88fc24a2..2a464673 100644 --- a/cloud/vmware/vca_nat.py +++ b/cloud/vmware/vca_nat.py @@ -130,7 +130,6 @@ EXAMPLES = ''' ''' import time -import json import xmltodict VALID_RULE_KEYS = ['rule_type', 'original_ip', 'original_port', diff --git a/clustering/consul.py b/clustering/consul.py index 609dce89..627f7fb6 100644 --- a/clustering/consul.py +++ b/clustering/consul.py @@ -191,11 +191,6 @@ EXAMPLES = ''' import sys try: - import json -except ImportError: - import simplejson as json - -try: import consul from requests.exceptions import ConnectionError python_consul_installed = True diff --git a/clustering/consul_kv.py b/clustering/consul_kv.py index bb7dea3a..b61c0ee1 100644 --- a/clustering/consul_kv.py +++ b/clustering/consul_kv.py @@ -123,11 +123,6 @@ EXAMPLES = ''' import sys try: - import json -except ImportError: - import simplejson as json - -try: import consul from requests.exceptions import ConnectionError python_consul_installed = True diff --git a/database/misc/riak.py b/database/misc/riak.py index 453e6c15..1f1cd11e 100644 --- a/database/misc/riak.py +++ b/database/misc/riak.py @@ -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): diff --git a/monitoring/boundary_meter.py b/monitoring/boundary_meter.py index 99cb74f8..ef681704 100644 --- a/monitoring/boundary_meter.py +++ b/monitoring/boundary_meter.py @@ -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 diff --git a/monitoring/sensu_check.py b/monitoring/sensu_check.py index 9a004d37..09edae63 100644 --- a/monitoring/sensu_check.py +++ b/monitoring/sensu_check.py @@ -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: diff --git a/monitoring/stackdriver.py b/monitoring/stackdriver.py index 7b3688cb..25af77ec 100644 --- a/monitoring/stackdriver.py +++ b/monitoring/stackdriver.py @@ -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""" diff --git a/monitoring/uptimerobot.py b/monitoring/uptimerobot.py index bdff8f1f..65d963cd 100644 --- a/monitoring/uptimerobot.py +++ b/monitoring/uptimerobot.py @@ -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 diff --git a/network/ipify_facts.py b/network/ipify_facts.py index 8f509dd2..95bf549b 100644 --- a/network/ipify_facts.py +++ b/network/ipify_facts.py @@ -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): diff --git a/packaging/language/composer.py b/packaging/language/composer.py index 95b0eb3a..5d1ec7b1 100644 --- a/packaging/language/composer.py +++ b/packaging/language/composer.py @@ -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() diff --git a/packaging/language/npm.py b/packaging/language/npm.py index a52b7599..43fa1f32 100644 --- a/packaging/language/npm.py +++ b/packaging/language/npm.py @@ -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): diff --git a/packaging/os/pacman.py b/packaging/os/pacman.py index 1f955fa2..7aa5bf45 100644 --- a/packaging/os/pacman.py +++ b/packaging/os/pacman.py @@ -109,7 +109,6 @@ EXAMPLES = ''' - pacman: name=baz state=absent force=yes ''' -import json import shlex import os import re diff --git a/packaging/os/pkgin.py b/packaging/os/pkgin.py index 0f2714b6..cdba6a92 100644 --- a/packaging/os/pkgin.py +++ b/packaging/os/pkgin.py @@ -63,7 +63,6 @@ EXAMPLES = ''' ''' -import json import shlex import os import sys diff --git a/packaging/os/pkgng.py b/packaging/os/pkgng.py index 0eafcb6d..ad097aae 100644 --- a/packaging/os/pkgng.py +++ b/packaging/os/pkgng.py @@ -85,7 +85,6 @@ EXAMPLES = ''' ''' -import json import shlex import os import re diff --git a/packaging/os/portinstall.py b/packaging/os/portinstall.py index b4e30441..a5d0e510 100644 --- a/packaging/os/portinstall.py +++ b/packaging/os/portinstall.py @@ -58,7 +58,6 @@ EXAMPLES = ''' ''' -import json import shlex import os import sys diff --git a/packaging/os/urpmi.py b/packaging/os/urpmi.py index d344f2e7..0b9ec929 100644 --- a/packaging/os/urpmi.py +++ b/packaging/os/urpmi.py @@ -73,7 +73,6 @@ EXAMPLES = ''' ''' -import json import shlex import os import sys diff --git a/source_control/github_hooks.py b/source_control/github_hooks.py index d75fcb15..9f664875 100644 --- a/source_control/github_hooks.py +++ b/source_control/github_hooks.py @@ -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 = ''' diff --git a/system/puppet.py b/system/puppet.py index 2a70da3c..d4f69b1d 100644 --- a/system/puppet.py +++ b/system/puppet.py @@ -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 = ''' --- diff --git a/web_infrastructure/jira.py b/web_infrastructure/jira.py index 79cfb72d..dded069f 100644 --- a/web_infrastructure/jira.py +++ b/web_infrastructure/jira.py @@ -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): |