From 7c2c2d6130648fb6dd7c0e52d802cc6eff39ef95 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 30 Nov 2009 15:28:09 -0500 Subject: Add option to have ipautil.run() not raise an exception There are times where a caller will want to determine the course of action based on the returncode instead of relying on it != 0. This also lets the caller get the contents of stdout and stderr. --- ipaserver/install/certs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ipaserver/install/certs.py') diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py index ca535120..c4923a75 100644 --- a/ipaserver/install/certs.py +++ b/ipaserver/install/certs.py @@ -382,7 +382,7 @@ class CertDB(object): root_nicknames = self.find_root_cert(nickname) fd = open(self.cacert_fname, "w") for root in root_nicknames: - (cert, stderr) = self.run_certutil(["-L", "-n", root, "-a"]) + (cert, stderr, returncode) = self.run_certutil(["-L", "-n", root, "-a"]) fd.write(cert) fd.close() os.chmod(self.cacert_fname, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) @@ -424,13 +424,13 @@ class CertDB(object): def get_cert_from_db(self, nickname): try: args = ["-L", "-n", nickname, "-a"] - (cert, err) = self.run_certutil(args) + (cert, err, returncode) = self.run_certutil(args) return cert except ipautil.CalledProcessError: return '' def find_cacert_serial(self): - (out,err) = self.run_certutil(["-L", "-n", self.cacert_name]) + (out, err, returncode) = self.run_certutil(["-L", "-n", self.cacert_name]) data = out.split('\n') for line in data: x = re.match(r'\s+Serial Number: (\d+) .*', line) @@ -485,7 +485,7 @@ class CertDB(object): "-f", self.passwd_fname] if not self.self_signed_ca: args.append("-a") - (stdout, stderr) = self.run_certutil(args) + (stdout, stderr, returncode) = self.run_certutil(args) os.remove(self.noise_fname) return (stdout, stderr) @@ -746,7 +746,7 @@ class CertDB(object): if passwd_fname: args = args + ["-w", passwd_fname] try: - (stdout, stderr) = ipautil.run(args) + (stdout, stderr, returncode) = ipautil.run(args) except ipautil.CalledProcessError, e: if e.returncode == 17: raise RuntimeError("incorrect password") -- cgit