Skip to content

Commit

Permalink
Remove use of simplejson throughout code base (ansible#43548)
Browse files Browse the repository at this point in the history
* Remove use of simplejson throughout code base. Fixes ansible#42761

* Address failing tests

* Remove simplejson from contrib and other outlying files

* Add changelog fragment for simplejson removal
  • Loading branch information
sivel authored Aug 10, 2018
1 parent 9634693 commit c1c229c
Show file tree
Hide file tree
Showing 55 changed files with 73 additions and 285 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/remove-simplejson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_changes:
- Remove support for simplejson (https://github.com/ansible/ansible/issues/42761)
5 changes: 1 addition & 4 deletions contrib/inventory/abiquo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@
import time
import ConfigParser

try:
import json
except ImportError:
import simplejson as json
import json

from ansible.module_utils.urls import open_url

Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/apache-libcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@
from libcloud.compute.providers import get_driver
import libcloud.security as sec

try:
import json
except ImportError:
import simplejson as json
import json


class LibcloudInventory(object):
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/brook.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@
except ImportError:
from configparser import ConfigParser

try:
import json
except ImportError:
import simplejson as json
import json

try:
import libbrook
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/cloudforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
import warnings
from ansible.errors import AnsibleError

try:
import json
except ImportError:
import simplejson as json
import json


class CloudFormsInventory(object):
Expand Down
7 changes: 1 addition & 6 deletions contrib/inventory/cloudstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@

import sys
import argparse

try:
import json
except:
import simplejson as json

import json

try:
from cs import CloudStack, CloudStackException, read_config
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/cobbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@
from time import time
import xmlrpclib

try:
import json
except ImportError:
import simplejson as json
import json

from six import iteritems

Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/collins.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@
from time import time
import traceback

try:
import json
except ImportError:
import simplejson as json
import json

from six import iteritems
from six.moves.urllib.parse import urlencode
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/consul_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ def setup_logging():
setup_logging()


try:
import json
except ImportError:
import simplejson as json
import json

try:
import consul
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/digital_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@
except ImportError:
import configparser as ConfigParser

try:
import json
except ImportError:
import simplejson as json
import json


class DoManager:
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@
from six.moves import configparser
from collections import defaultdict

try:
import json
except ImportError:
import simplejson as json
import json

DEFAULTS = {
'all_elasticache_clusters': 'False',
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
import re
import string
from optparse import OptionParser
try:
import json
except:
import simplejson as json
import json

# Options
# ------------------------------
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@
import logging
logging.getLogger('libcloud.common.google').addHandler(logging.NullHandler())

try:
import json
except ImportError:
import simplejson as json
import json

try:
from libcloud.compute.types import Provider
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@

from landscape_api.base import API, HTTPError

try:
import json
except ImportError:
import simplejson as json
import json

_key = 'landscape'

Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@
import argparse
from time import time

try:
import json
except ImportError:
import simplejson as json
import json

try:
from chube import load_chube_config
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
author: Michael Scherer
'''

try:
import json
except ImportError:
import simplejson as json
import json
import os
import os.path
import sys
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/openstack_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@
from distutils.version import StrictVersion
from io import StringIO

try:
import json
except:
import simplejson as json
import json

import openstack as sdk
from openstack.cloud import inventory as sdk_inventory
Expand Down
6 changes: 1 addition & 5 deletions contrib/inventory/ovirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@
import ConfigParser
from collections import defaultdict

try:
import json
except ImportError:
# noinspection PyUnresolvedReferences,PyPackageRequirements
import simplejson as json
import json

try:
# noinspection PyUnresolvedReferences
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/ovirt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@
except ImportError:
import configparser

try:
import json
except ImportError:
import simplejson as json
import json

try:
import ovirtsdk4 as sdk
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/packet_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
import traceback


try:
import json
except ImportError:
import simplejson as json
import json


ini_section = 'packet'
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
#
# { "groups": ["utility", "databases"], "a": false, "b": true }

try:
import json
except ImportError:
import simplejson as json
import json
import os
import sys
from optparse import OptionParser
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/rax.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@

from six import iteritems

try:
import json
except ImportError:
import simplejson as json
import json

try:
import pyrax
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/rudder.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@
from ansible.module_utils.six.moves import configparser
from ansible.module_utils.six.moves.urllib.parse import urlparse

try:
import json
except ImportError:
import simplejson as json
import json


class RudderInventory(object):
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/scaleway.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
import time
import traceback

try:
import json
except ImportError:
import simplejson as json
import json

EMPTY_GROUP = {
'children': [],
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/serf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@
# https://pypi.org/project/serfclient/
from serfclient import SerfClient, EnvironmentConfig

try:
import json
except ImportError:
import simplejson as json
import json

_key = 'serf'

Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/softlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
import re
import argparse
import itertools
try:
import json
except:
import simplejson as json
import json


class SoftLayerInventory(object):
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/spacewalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@
from optparse import OptionParser
import subprocess
import ConfigParser
import json

from six import iteritems

try:
import json
except:
import simplejson as json

base_dir = os.path.dirname(os.path.realpath(__file__))
default_ini_file = os.path.join(base_dir, "spacewalk.ini")
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/ssh_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
import sys
from collections import MutableSequence

try:
import json
except ImportError:
import simplejson as json
import json

import paramiko

Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/stacki.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
import yaml
from distutils.version import StrictVersion

try:
import json
except:
import simplejson as json
import json

try:
import requests
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
from paramiko import SSHConfig
from optparse import OptionParser
from collections import defaultdict
try:
import json
except Exception:
import simplejson as json
import json

from ansible.module_utils._text import to_text
from ansible.module_utils.six.moves import StringIO
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/vbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import sys
from subprocess import Popen, PIPE

try:
import json
except ImportError:
import simplejson as json
import json


class SetEncoder(json.JSONEncoder):
Expand Down
5 changes: 1 addition & 4 deletions contrib/inventory/zabbix.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
file=sys.stderr)
sys.exit(1)

try:
import json
except:
import simplejson as json
import json


class ZabbixInventory(object):
Expand Down
3 changes: 2 additions & 1 deletion docs/docsite/rst/user_guide/intro_bsd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ versions of sshpass do not deal particularly well with BSD login prompts, so whe
[freebsd]
mybsdhost1 ansible_connection=paramiko

Ansible is agentless by default, however certain software is required on the target machines. Using Python 2.4 on the agents requires an additional py-simplejson package/library to be installed, however this library is already included in Python 2.5 and above.
Ansible is agentless by default, however certain software is required on the target machines.

Operating without Python is possible with the ``raw`` module. Although this module can be used to bootstrap Ansible and install Python on BSD variants (see below), it is very limited and the use of Python is required to make full use of Ansible's features.

.. _bootstrap_bsd:
Expand Down
Loading

0 comments on commit c1c229c

Please sign in to comment.