public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Joshua G Lock <joshua.g.lock@linux.intel.com>
To: Jose Lamego <jose.a.lamego@linux.intel.com>,
	 openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 20/20] oeqa.utils.readconfig: Read self-test configuration file
Date: Tue, 09 Aug 2016 10:19:51 +0100	[thread overview]
Message-ID: <1470734391.2881.7.camel@linux.intel.com> (raw)
In-Reply-To: <4a01440ac6492364d910f3c7d87ab00bb1dac5b5.1470671417.git.jose.a.lamego@linux.intel.com>

On Mon, 2016-08-08 at 09:23 -0700, Jose Lamego wrote:
> Improve oeqa-selftest capabilities and UX by placing
> test configuration features and variables into a separate
> configuration file.
> This library reads a configuration file located at the
> oeqa/selftest/conf directory with same name as the caller
> file and the conf extension.

This patch to add the oeqa.utils.readconfig module should really be
applied before all of the changes which make use it. It's a relatively
minor niggle, but this should really be 1/20.

> 
> [Yocto 9389]
> 
> Signed-off-by: Jose Lamego <jose.a.lamego@linux.intel.com>
> ---
>  meta/lib/oeqa/utils/readconfig.py | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>  create mode 100644 meta/lib/oeqa/utils/readconfig.py
> 
> diff --git a/meta/lib/oeqa/utils/readconfig.py
> b/meta/lib/oeqa/utils/readconfig.py
> new file mode 100644
> index 0000000..1534ce7
> --- /dev/null
> +++ b/meta/lib/oeqa/utils/readconfig.py
> @@ -0,0 +1,18 @@
> +import os
> +import re
> +import configparser
> +
> +
> +def conffile(codefile):
> +    # Get test configurations from configuration file
> +    f = re.compile(r'(pyc?$)')
> +    fn = os.path.basename(codefile)
> +    configfile = os.path.join(os.path.dirname(codefile), 'conf',
> +                              f.sub('conf', fn))

This seems like it would be simpler with os.path.splitext()[1] ?

> +    config = configparser.SafeConfigParser()

Since Python 3.2 that's just ConfigParser()[2]. As we require Python
3.4 or newer for BitBake you can just use configparser.ConfigParser()
here.

> +    read_result = config.read(configfile)
> +    if read_result == []:
> +        raise configparser.Error("Failed to get test configuration
> from \
> +\"%s\". Verify that file exists and format is correct."
> +                                 % configfile)
> +    return config
> -- 
> 1.8.3.1
> 

Regards,

Joshua

1. https://docs.python.org/3/library/os.path.html#os.path.splitext
2. https://docs.python.org/3/whatsnew/3.2.html


  reply	other threads:[~2016-08-09  9:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 16:22 [PATCH 00/20] oeqa: Split configuration from the code Jose Lamego
2016-08-08 16:22 ` [PATCH 01/20] oeqa.selftest.archiver: Split configuration from code Jose Lamego
2016-08-08 16:22 ` [PATCH 02/20] oeqa.selftest._sstatetests_noauto: " Jose Lamego
2016-08-08 16:22 ` [PATCH 03/20] oeqa.selftest.bblayers: " Jose Lamego
2016-08-08 16:22 ` [PATCH 04/20] oeqa.selftest.bbtests: " Jose Lamego
2016-08-08 16:22 ` [PATCH 05/20] oeqa.selftest.buildhistory: " Jose Lamego
2016-08-08 16:22 ` [PATCH 06/20] oeqa.selftest.buildoptions: " Jose Lamego
2016-08-08 16:22 ` [PATCH 07/20] oeqa.selftest.devtool: " Jose Lamego
2016-08-08 16:22 ` [PATCH 08/20] oeqa.selftest.imagefeatures: " Jose Lamego
2016-08-08 16:22 ` [PATCH 09/20] oeqa.selftest.layerappend: " Jose Lamego
2016-08-08 16:22 ` [PATCH 10/20] oeqa.selftest.lic-checksum: " Jose Lamego
2016-08-08 16:22 ` [PATCH 11/20] oeqa.selftest.manifest: " Jose Lamego
2016-08-08 16:23 ` [PATCH 12/20] oeqa.selftest.oescripts: " Jose Lamego
2016-08-08 16:23 ` [PATCH 13/20] oeqa.selftest.pkgdata: " Jose Lamego
2016-08-08 16:23 ` [PATCH 14/20] oeqa.selftest.prservice: " Jose Lamego
2016-08-08 16:23 ` [PATCH 15/20] oeqa.selftest.recipetool: " Jose Lamego
2016-08-08 16:23 ` [PATCH 16/20] oeqa.selftest.runtime-test: " Jose Lamego
2016-08-08 16:23 ` [PATCH 17/20] oeqa.selftest.signing: " Jose Lamego
2016-08-08 16:23 ` [PATCH 18/20] oeqa.selftest.sstatetests: " Jose Lamego
2016-08-08 16:23 ` [PATCH 19/20] oeqa.selftest.wic: " Jose Lamego
2016-08-09  7:26   ` Ed Bartosh
2016-08-09 15:20     ` Jose Lamego
2016-08-08 16:23 ` [PATCH 20/20] oeqa.utils.readconfig: Read self-test configuration file Jose Lamego
2016-08-09  9:19   ` Joshua G Lock [this message]
2016-08-09 12:09 ` [PATCH 00/20] oeqa: Split configuration from the code Richard Purdie

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=1470734391.2881.7.camel@linux.intel.com \
    --to=joshua.g.lock@linux.intel.com \
    --cc=jose.a.lamego@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox