summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2010-08-06 21:48:09 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-08-11 15:59:58 -0500
commit869537f3b703119ceb397b85ca38b4dff99b8d6b (patch)
tree7a04be825fba23bf7d74c10b6c65f1e33a44cf50
parentdef7fbd92d988851b94636175b5bab998407c4e6 (diff)
downloadbcfg2-869537f3b703119ceb397b85ca38b4dff99b8d6b.tar.gz
bcfg2-869537f3b703119ceb397b85ca38b4dff99b8d6b.tar.bz2
bcfg2-869537f3b703119ceb397b85ca38b4dff99b8d6b.zip
Don't assume python2.5 is being used on successful hashlib import
The hashlib module has been backported to earlier versions of python. If we assume that 2.5 is in use, then python will go crazy looking for stuff that doesn't exist in earlier versions. This patch will allow older versions of python installed alongside a standalone hashlib module to work properly. Signed-off-by: Sol Jerome <sol.jerome@gmail.com> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@6004 ce84e21b-d406-0410-9b95-82705330c041
-rwxr-xr-xsrc/lib/Client/Tools/rpmtools.py14
-rwxr-xr-xsrc/lib/Server/Admin/Reports.py5
-rw-r--r--src/lib/Server/Plugins/Packages.py6
3 files changed, 14 insertions, 11 deletions
diff --git a/src/lib/Client/Tools/rpmtools.py b/src/lib/Client/Tools/rpmtools.py
index c9385196f..e224a3fb3 100755
--- a/src/lib/Client/Tools/rpmtools.py
+++ b/src/lib/Client/Tools/rpmtools.py
@@ -21,19 +21,19 @@
__revision__ = '$Revision$'
import grp
-try:
- import hashlib
- py24compat = False
-except:
- # FIXME: Remove when client python dep is 2.5 or greater
- py24compat = True
- import md5
import optparse
import os
import pwd
import rpm
import stat
import sys
+if sys.version_info >= (2, 5):
+ import hashlib
+ py24compat = False
+else:
+ # FIXME: Remove when client python dep is 2.5 or greater
+ py24compat = True
+ import md5
# Determine what prelink tools we have available.
# The isprelink module is a python extension that examines the ELF headers
diff --git a/src/lib/Server/Admin/Reports.py b/src/lib/Server/Admin/Reports.py
index d11451852..91d25a0b0 100755
--- a/src/lib/Server/Admin/Reports.py
+++ b/src/lib/Server/Admin/Reports.py
@@ -12,9 +12,10 @@ from Bcfg2.Server.Reports.updatefix import update_database
from Bcfg2.Server.Reports.utils import *
from lxml.etree import XML, XMLSyntaxError
-try:
+# FIXME: Remove when server python dep is 2.5 or greater
+if sys.version_info >= (2, 5)::
from hashlib import md5
-except ImportError:
+else:
from md5 import md5
# Load django
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py
index d2517590c..61d6e1778 100644
--- a/src/lib/Server/Plugins/Packages.py
+++ b/src/lib/Server/Plugins/Packages.py
@@ -6,11 +6,13 @@ import logging
import lxml.etree
import os
import re
+import sys
import urllib2
-try:
+# FIXME: Remove when server python dep is 2.5 or greater
+if sys.version_info >= (2, 5)::
from hashlib import md5
-except ImportError:
+else:
from md5 import md5
import Bcfg2.Logger