summaryrefslogtreecommitdiffstats
path: root/ipa-python/ipautil.py
diff options
context:
space:
mode:
authorrcritten@redhat.com <rcritten@redhat.com>2007-11-30 15:53:02 -0500
committerrcritten@redhat.com <rcritten@redhat.com>2007-11-30 15:53:02 -0500
commitc32a960cae3eca434369502fb12b23b62ae6b2bf (patch)
tree0fee19d4c25781aa10aa2fe8199e5dc9c04192e6 /ipa-python/ipautil.py
parentb04bed4e82e4497b379c433d88cd188348b39da7 (diff)
downloadfreeipa-c32a960cae3eca434369502fb12b23b62ae6b2bf.tar.gz
freeipa-c32a960cae3eca434369502fb12b23b62ae6b2bf.tar.xz
freeipa-c32a960cae3eca434369502fb12b23b62ae6b2bf.zip
Compatibility changes to work on RHEL 5 with python 2.4
Diffstat (limited to 'ipa-python/ipautil.py')
-rw-r--r--ipa-python/ipautil.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py
index df9231884..9b8412d23 100644
--- a/ipa-python/ipautil.py
+++ b/ipa-python/ipautil.py
@@ -33,6 +33,22 @@ from string import lower
import re
import xmlrpclib
import datetime
+try:
+ from subprocess import CalledProcessError
+ class CalledProcessError(subprocess.CalledProcessError):
+ def __init__(self, returncode, cmd):
+ super(CalledProcessError, self).__init__(returncode, cmd)
+except ImportError:
+ # Python 2.4 doesn't implement CalledProcessError
+ class CalledProcessError(Exception):
+ """This exception is raised when a process run by check_call() returns
+ a non-zero exit status. The exit status will be stored in the
+ returncode attribute."""
+ def __init__(self, returncode, cmd):
+ self.returncode = returncode
+ self.cmd = cmd
+ def __str__(self):
+ return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
def realm_to_suffix(realm_name):
s = realm_name.split(".")
@@ -63,7 +79,7 @@ def run(args, stdin=None):
logging.info(stderr)
if p.returncode != 0:
- raise subprocess.CalledProcessError(p.returncode, ' '.join(args))
+ raise self.CalledProcessError(p.returncode, ' '.join(args))
def file_exists(filename):
try: