[rhel7/master] Return program output as a string instead of a list
David Shea
dshea at redhat.com
Thu Jan 16 15:28:25 UTC 2014
commit dabc044dbde7d369a2e2007d7e384a6c912b2e22 changed the behavior of
iutil.exec* so that the output of the command was returned as a list
instead of a string. Fix that and rename some variables in _run_program
so it's more clear which type of output is being used where.
Revert ef9f31dc0ac47ce9568d94b5788c3ad82e5f851f since it is no longer
necessary.
Resolves: rhbz#1054142
---
pyanaconda/bootloader.py | 4 ++--
pyanaconda/iutil.py | 16 ++++++++--------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index cd0b24e..93241f6 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -2091,14 +2091,14 @@ class ZIPL(BootLoader):
buf = iutil.execWithCapture("zipl", [],
root=ROOT_PATH,
fatal=True)
- for line in buf:
+ for line in buf.splitlines():
if line.startswith("Preparing boot device: "):
# Output here may look like:
# Preparing boot device: dasdb (0200).
# Preparing boot device: dasdl.
# We want to extract the device name and pass that.
name = re.sub(r".+?: ", "", line)
- self.stage1_name = re.sub(r"(\s\(.+\))?\.$", "", name.strip())
+ self.stage1_name = re.sub(r"(\s\(.+\))?\.$", "", name)
if not self.stage1_name:
raise BootLoaderError("could not find IPL device")
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
index 421fbe9..4c1995b 100644
--- a/pyanaconda/iutil.py
+++ b/pyanaconda/iutil.py
@@ -81,16 +81,16 @@ def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_ou
stderr=subprocess.STDOUT,
preexec_fn=chroot, cwd=root, env=env)
- out = proc.communicate()[0]
- if out:
+ output_string = proc.communicate()[0]
+ if output_string:
if binary_output:
- out = [out]
+ output_lines = [output_string]
else:
- if out[-1] != "\n":
- out = out + "\n"
- out = out.splitlines(True)
+ if output_string[-1] != "\n":
+ output_string = output_string + "\n"
+ output_lines = output_string.splitlines(True)
- for line in out:
+ for line in output_lines:
if log_output:
program_log.info(line.strip())
@@ -103,7 +103,7 @@ def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_ou
program_log.debug("Return code: %d" % proc.returncode)
- return (proc.returncode, out)
+ return (proc.returncode, output_string)
def execWithRedirect(command, argv, stdin=None, stdout=None,
stderr=None, root='/', env_prune=[], log_output=True, binary_output=False):
--
1.8.4.2
More information about the anaconda-patches
mailing list