From af07f60e2e5c9c26ab1ef1d0ecc0565672a85f56 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 17 Sep 2012 10:31:16 -0400 Subject: added json, md5 to Bcfg2.Compat --- src/lib/Bcfg2/Server/Plugins/Ohai.py | 16 ++-------------- src/lib/Bcfg2/Server/Plugins/Probes.py | 14 ++------------ src/lib/Bcfg2/Server/Plugins/SSLCA.py | 7 +------ 3 files changed, 5 insertions(+), 32 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins') diff --git a/src/lib/Bcfg2/Server/Plugins/Ohai.py b/src/lib/Bcfg2/Server/Plugins/Ohai.py index 20f9ba877..35e385a77 100644 --- a/src/lib/Bcfg2/Server/Plugins/Ohai.py +++ b/src/lib/Bcfg2/Server/Plugins/Ohai.py @@ -1,22 +1,10 @@ import lxml.etree import os - import logging -logger = logging.getLogger('Bcfg2.Plugins.Ohai') - import Bcfg2.Server.Plugin +from Bcfg2.Compat import json -try: - import json -except: - # FIXME: can be removed when server prereq is >= python 2.6 - # necessary for clients without the in-tree json module - try: - import simplejson as json - except: - logger.error("Unable to load any json modules. Make sure " - "python-simplejson is installed.") - raise ImportError +logger = logging.getLogger('Bcfg2.Plugins.Ohai') probecode = """#!/bin/sh diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index 79f2ae87e..68cdce6e8 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -7,7 +7,7 @@ import operator import lxml.etree import Bcfg2.Server import Bcfg2.Server.Plugin -from Bcfg2.Compat import any +from Bcfg2.Compat import any, json try: from django.db import models @@ -15,16 +15,6 @@ try: except ImportError: has_django = False -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 has_yaml = True @@ -93,7 +83,7 @@ class ProbeData(str): @property def json(self): - if self._json is None and has_json: + if self._json is None: try: self._json = json.loads(self.data) except ValueError: diff --git a/src/lib/Bcfg2/Server/Plugins/SSLCA.py b/src/lib/Bcfg2/Server/Plugins/SSLCA.py index b02802ac8..8ca95ff62 100644 --- a/src/lib/Bcfg2/Server/Plugins/SSLCA.py +++ b/src/lib/Bcfg2/Server/Plugins/SSLCA.py @@ -5,13 +5,8 @@ import posixpath import tempfile import os from subprocess import Popen, PIPE, STDOUT -# Compatibility import -from Bcfg2.Compat import ConfigParser +from Bcfg2.Compat import ConfigParser, md5 -try: - from hashlib import md5 -except ImportError: - from md5 import md5 class SSLCA(Bcfg2.Server.Plugin.GroupSpool): """ -- cgit v1.2.3-1-g7c22