summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-06-17 08:03:26 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-06-17 08:03:26 -0400
commit3ec2fc27deefc647127c9e729221826a90fd7a96 (patch)
treeb25a52fa6cf1a7c4d3fff561af76e62fb237d3b2
parent18368164103d047cf742f0679b4a8cb9ab5cb9c2 (diff)
downloadbcfg2-3ec2fc27deefc647127c9e729221826a90fd7a96.tar.gz
bcfg2-3ec2fc27deefc647127c9e729221826a90fd7a96.tar.bz2
bcfg2-3ec2fc27deefc647127c9e729221826a90fd7a96.zip
Improved handling of JSON data from probes
-rw-r--r--doc/server/plugins/probes/index.txt6
-rw-r--r--src/lib/Server/Plugins/Probes.py17
2 files changed, 13 insertions, 10 deletions
diff --git a/doc/server/plugins/probes/index.txt b/doc/server/plugins/probes/index.txt
index d52e7bb95..5b1f9e259 100644
--- a/doc/server/plugins/probes/index.txt
+++ b/doc/server/plugins/probes/index.txt
@@ -128,12 +128,12 @@ string-like object that has some interesting and salient features:
* If the data is a valid XML document, then
``metadata.Probes['script-name'].xdata`` will be an
``lxml.etree._Element`` object representing the XML data.
-* If the data is a valid JSON document, and the Python ``json`` module
- is installed (included in Python 2.6 onward), then
+* If the data is a valid JSON document, and either the Python ``json``
+ or ``simplejson`` module is installed, then
``metadata.Probes['script-name'].json`` will be a data structure
representing the JSON data.
* If the data is a valid YAML document, and either the Python ``yaml``
- module or ``syck`` module is installed, then
+ or ``syck`` module is installed, then
``metadata.Probes['script-name'].yaml`` will be a data structure
representing the YAML data.
diff --git a/src/lib/Server/Plugins/Probes.py b/src/lib/Server/Plugins/Probes.py
index b07c4dfd3..ec0f294dd 100644
--- a/src/lib/Server/Plugins/Probes.py
+++ b/src/lib/Server/Plugins/Probes.py
@@ -6,19 +6,22 @@ try:
import json
has_json = True
except ImportError:
- has_json = False
+ try:
+ import simplejson as json
+ has_json = True
+ except ImportError:
+ has_json = False
try:
import syck
has_syck = True
except ImportError:
has_syck = False
-
-try:
- import yaml
- has_yaml = True
-except ImportError:
- has_yaml = False
+ try:
+ import yaml
+ has_yaml = True
+ except ImportError:
+ has_yaml = False
import Bcfg2.Server.Plugin