summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-24 13:25:01 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-25 11:58:48 -0400
commit3428eab79ab21d1ecee6d2f8edff083a2cccdf79 (patch)
tree9f19144fe7d5161c9208f50aa0b6a9945682a967
parent6d4d8df68717780239fad273dd722359db10e64b (diff)
downloadbcfg2-3428eab79ab21d1ecee6d2f8edff083a2cccdf79.tar.gz
bcfg2-3428eab79ab21d1ecee6d2f8edff083a2cccdf79.tar.bz2
bcfg2-3428eab79ab21d1ecee6d2f8edff083a2cccdf79.zip
made json optional again
-rw-r--r--src/lib/Bcfg2/Compat.py6
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Ohai.py9
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Yum.py7
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py13
-rwxr-xr-xsrc/sbin/bcfg2-yum-helper5
5 files changed, 29 insertions, 11 deletions
diff --git a/src/lib/Bcfg2/Compat.py b/src/lib/Bcfg2/Compat.py
index 4daba5b8c..9aeda6d36 100644
--- a/src/lib/Bcfg2/Compat.py
+++ b/src/lib/Bcfg2/Compat.py
@@ -245,12 +245,6 @@ except ImportError:
try:
- import json
-except ImportError:
- import simplejson as json
-
-
-try:
from functools import wraps
except ImportError:
def wraps(wrapped):
diff --git a/src/lib/Bcfg2/Server/Plugins/Ohai.py b/src/lib/Bcfg2/Server/Plugins/Ohai.py
index 35e385a77..052597f84 100644
--- a/src/lib/Bcfg2/Server/Plugins/Ohai.py
+++ b/src/lib/Bcfg2/Server/Plugins/Ohai.py
@@ -2,7 +2,13 @@ import lxml.etree
import os
import logging
import Bcfg2.Server.Plugin
-from Bcfg2.Compat import json
+
+# pylint: disable=F0401
+try:
+ import json
+except ImportError:
+ import simplejson as json
+# pylint: enable=F0401
logger = logging.getLogger('Bcfg2.Plugins.Ohai')
@@ -19,6 +25,7 @@ else
fi
"""
+
class OhaiCache(object):
def __init__(self, dirname):
self.dirname = dirname
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
index 4224798a8..04d4e9f74 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
@@ -61,7 +61,7 @@ from subprocess import Popen, PIPE
import Bcfg2.Server.Plugin
# pylint: disable=W0622
from Bcfg2.Compat import StringIO, cPickle, HTTPError, URLError, \
- ConfigParser, json, any
+ ConfigParser, any
# pylint: enable=W0622
from Bcfg2.Server.Plugins.Packages.Collection import Collection
from Bcfg2.Server.Plugins.Packages.Source import SourceInitError, Source, \
@@ -81,11 +81,16 @@ except ImportError:
try:
import yum
+ try:
+ import json
+ except ImportError:
+ import simplejson as json
HAS_YUM = True
except ImportError:
HAS_YUM = False
LOGGER.info("Packages: No yum libraries found; forcing use of internal "
"dependency resolver")
+
# pylint: enable=E0611,F0401
XP = '{http://linux.duke.edu/metadata/common}'
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index 9e6b43d7b..58723e392 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -9,7 +9,6 @@ import operator
import lxml.etree
import Bcfg2.Server
import Bcfg2.Server.Plugin
-from Bcfg2.Compat import json
# pylint: disable=F0401
try:
@@ -32,6 +31,16 @@ except ImportError:
pass
try:
+ import json
+ HAS_JSON = True
+except ImportError:
+ try:
+ import simplejson as json
+ HAS_JSON = True
+ except ImportError:
+ HAS_JSON = False
+
+try:
import syck as yaml
import syck.error as YAMLError
HAS_YAML = True
@@ -89,7 +98,7 @@ class ProbeData(str):
@property
def json(self):
""" The probe data as a decoded JSON data structure """
- if self._json is None:
+ if self._json is None and HAS_JSON:
try:
self._json = json.loads(self.data)
except ValueError:
diff --git a/src/sbin/bcfg2-yum-helper b/src/sbin/bcfg2-yum-helper
index 07f9b81b0..859ec36b6 100755
--- a/src/sbin/bcfg2-yum-helper
+++ b/src/sbin/bcfg2-yum-helper
@@ -10,7 +10,10 @@ import sys
import yum
import logging
from optparse import OptionParser
-from Bcfg2.Compat import json
+try:
+ import json
+except ImportError:
+ import simplejson as json
LOGGER = None