On Tue, Oct 28, 2014 at 08:56:24AM -0400, Anne Mulhern wrote:
----- Original Message -----
> From: "Brian C. Lane" <bcl(a)redhat.com>
> To: anaconda-patches(a)lists.fedorahosted.org
> Sent: Monday, October 27, 2014 8:49:26 PM
> Subject: [master] Strip lvm WARNING: lines from output (#1157864)
>
> LVM has started including a pile of WARNING: lines in its output. These
> need to be removed before the return value lvm() is used.
> ---
> blivet/devicelibs/lvm.py | 41 ++++++++++++++++++++++++++---------------
> 1 file changed, 26 insertions(+), 15 deletions(-)
>
> diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
> index 09a4956..c521248 100644
> --- a/blivet/devicelibs/lvm.py
> +++ b/blivet/devicelibs/lvm.py
> @@ -216,13 +216,22 @@ def is_valid_thin_pool_chunk_size(size, discard=False):
> else:
> return (size % LVM_THINP_MIN_CHUNK_SIZE == 0)
>
> +def strip_lvm_warnings(buf):
> + """ Strip out lines starting with WARNING:
Strip out lvm warning lines.
> +
> + :param str buf: A string returned from lvm
> + :returns: A list of strings
:returns: A list of strings, with warning lines stripped.
My reasoning for changes above is that
the method is so simple and so little used that the only
reason for making it a separate method is because we expect to have
it grow as LVM develops sneakier and sneakier ways of
inserting warnings into the output. So the comments
might as well be generic in that expectation.
> + :rtype: list
"list of str" seems better to me.
> + """
> + return [l for l in buf.splitlines() if l and not
> l.strip().startswith("WARNING:")]
lstrip() (instead of strip()) makes slightly more sense here.
Thanks, fixed all these locally.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)