All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Lock <joshua.g.lock@linux.intel.com>
To: Markus Lehtonen <markus.lehtonen@linux.intel.com>,
	 openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] oeqa.utils.metadata: cope with invalid lines in os-release file
Date: Wed, 26 Apr 2017 15:47:26 +0100	[thread overview]
Message-ID: <1493218046.3433.25.camel@linux.intel.com> (raw)
In-Reply-To: <20170426143942.19020-1-markus.lehtonen@linux.intel.com>

On Wed, 2017-04-26 at 17:39 +0300, Markus Lehtonen wrote:
> Don't crash if every line in /etc/os-release does not adhere to the
> expected "key=val" format. E.g. CentOS 7 has empty lines in the file.
> 
> Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
> ---
>  meta/lib/oeqa/utils/metadata.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/lib/oeqa/utils/metadata.py
> b/meta/lib/oeqa/utils/metadata.py
> index cb81155e54..d291ddb960 100644
> --- a/meta/lib/oeqa/utils/metadata.py
> +++ b/meta/lib/oeqa/utils/metadata.py
> @@ -20,8 +20,10 @@ def get_os_release():
>          return None
>      with open(os_release_file) as fobj:
>          for line in fobj:
> -            key, value = line.split('=', 1)
> -            data[key.strip().lower()] = value.strip().strip('"')
> +            split = line.split('=', 1)
> +            if len(split) == 2:
> +                key, value = split
> +                data[key.strip().lower()] = value.strip().strip('"')

We have a function to read os-release in oe.lsb, return_dict_osr().

It handles this situation slightly differently, but the real reason I'm
pointing this out is that it seems like we could factor out a shared
function to be used both here and in oe.lsb ?

Joshua


  reply	other threads:[~2017-04-26 14:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 14:39 [PATCH] oeqa.utils.metadata: cope with invalid lines in os-release file Markus Lehtonen
2017-04-26 14:47 ` Joshua Lock [this message]
2017-04-27  7:57   ` Markus Lehtonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1493218046.3433.25.camel@linux.intel.com \
    --to=joshua.g.lock@linux.intel.com \
    --cc=markus.lehtonen@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.