This patch set makes execWithCapture capable of raising an exception if the subprocess call returns a non-zero exit code. The option, fatal, defaults to being false.
Further, we turn this option on when calling zipl to install the boot loader, which is bug #730023.
This patch is for rhel6-branch, as I'm told there will be a different way of handling this in newui/master.
-jlk
execWithCapture normally doesn't care about non-zero exits in called processes. In some cases (most?) this is preferred. In few cases we do actually care about the success or failure of the execution. "fatal" provides a boolean that will allow callers to decide if they care or not.
An OSError is raised because there is already code to catch that in the except section.
Related: rhbz#730023 --- iutil.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/iutil.py b/iutil.py index 9f594d3..fd54dde 100644 --- a/iutil.py +++ b/iutil.py @@ -182,8 +182,10 @@ def execWithRedirect(command, argv, stdin = None, stdout = None, # @param stdin The file descriptor to read stdin from. # @param stderr The file descriptor to redirect stderr to. # @param root The directory to chroot to before running command. +# @param fatal Boolean to determine if non-zero exit is fatal. # @return The output of command from stdout. -def execWithCapture(command, argv, stdin = None, stderr = None, root='/'): +def execWithCapture(command, argv, stdin = None, stderr = None, root='/', + fatal = False): def chroot(): os.chroot(root)
@@ -240,6 +242,10 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'):
if proc.returncode is not None: break + # if we have anything other than a clean exit, and we get the fatal + # option, raise the OSError. + if proc.returncode and fatal: + raise OSError('Non-zero return code: %s' % proc.returncode) except OSError as e: log.error ("Error running " + command + ": " + e.strerror) closefds()
If zipl doesn't succeed, the install won't reboot when finished. This is not an acceptable situation. --- booty/s390.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/booty/s390.py b/booty/s390.py index 9fd9c1e..c237b5a 100644 --- a/booty/s390.py +++ b/booty/s390.py @@ -156,7 +156,8 @@ class s390BootloaderInfo(bootloaderInfo):
if not justConfigFile: rc = iutil.execWithCapture("zipl", [], root = instRoot, - stderr = "/dev/stderr") + stderr = "/dev/stderr", + fatal = True) for line in rc.splitlines(): if line.startswith("Preparing boot device: "): # Output here may look like:
On Tue, 2012-07-03 at 14:21 -0700, Jesse Keating wrote:
This patch set makes execWithCapture capable of raising an exception if the subprocess call returns a non-zero exit code. The option, fatal, defaults to being false.
I'm not crazy about the trickiness of raising OSError, but it'll do the job.
Further, we turn this option on when calling zipl to install the boot loader, which is bug #730023.
This patch is for rhel6-branch, as I'm told there will be a different way of handling this in newui/master.
Nobody is actually doing the work as of now, though. I'd go ahead and push to master just in case.
-jlk
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/anaconda-patches
anaconda-patches@lists.fedorahosted.org