diff options
author | Toshio Kuratomi <toshio@fedoraproject.org> | 2016-01-11 12:47:21 -0800 |
---|---|---|
committer | Toshio Kuratomi <toshio@fedoraproject.org> | 2016-01-11 13:06:22 -0800 |
commit | d6af6f8477d3d1600f3907d4ec1b216c94e67d52 (patch) | |
tree | f0fe4574d56af1193c4a2c835bf4ac7caad2375d /monitoring | |
parent | 39c3004337b688cd44e711f6eeeb9bc161f0d318 (diff) | |
download | ansible-modules-extras-json-imports-fallback.tar.gz |
Update for modules which import json.json-imports-fallback
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
Diffstat (limited to 'monitoring')
-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 |
4 files changed, 35 insertions, 9 deletions
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 |