All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Lock <josh@linux.intel.com>
To: poky@yoctoproject.org
Subject: Re: [PATCH 1/2] distro_check.py: Add a new function to reduce the repeat code
Date: Fri, 13 May 2011 10:13:28 -0700	[thread overview]
Message-ID: <1305306808.2023.18.camel@scimitar> (raw)
In-Reply-To: <767202df6b1d0044bd0b56bf4f50b8a69ceb18b5.1305269419.git.lei.mei@intel.com>

On Thu, 2011-01-13 at 15:04 +0800, Mei Lei wrote:
> From: Mei Lei <lei.mei@intel.com>
> 
> A lot of repeat code in distrodata.bbclass when creating log file, we
> can define a function called create_log_file to do it.

I like the intent of the patch, some comments on coding style below.

> 
> Signed-off-by: Mei Lei <lei.mei@intel.com>
> ---
>  meta/lib/oe/distro_check.py |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py
> index c85d4fb..134e92a 100644
> --- a/meta/lib/oe/distro_check.py
> +++ b/meta/lib/oe/distro_check.py
> @@ -341,6 +341,21 @@ def compare_in_distro_packages_list(distro_check_dir, d):
>      bb.note("Matching: %s" % matching_distros)
>      return matching_distros
>  
> +def create_log_file(d, logname):
> +    #logpath = bb.data.getVar('LOG_DIR', e.data, 1)

No need for this commented line.

> +    logpath = bb.data.getVar('LOG_DIR', d, 1)

We are trying to move towards using Boolean values where appropriate to
aid readability, this line should be:

logpath = bb.data.getVar('LOG_DIR', d, True)

> +    bb.utils.mkdirhier(logpath)
> +    logfile = logpath +"/" + logname.split(".")[0] + ".%s.csv" % bb.data.getVar('DATETIME', d, 1)

Can you use the Python standard library functions for handling filenames
here? And a boolean True in the getVar() call.

Something like the following feels more Pythonic:

logfn, logext = os.path.splitext(logname)
logfile = os.path.join(logpath, "%s.%s.csv" % (logfn,
bb.data.getVar('DATETIME', d, True))

> +    if not os.path.exists(logfile):
> +            slogfile = os.path.join(logpath, logname)
> +            if os.path.exists(slogfile):
> +                    os.remove(slogfile)
> +            os.system("touch %s" % logfile)
> +            os.symlink(logfile, slogfile)
> +            bb.data.setVar('LOG_FILE', logfile, d)
> +    return logfile
> +
> +
>  def save_distro_check_result(result, datetime, d):
>      pn = bb.data.getVar('PN', d, True)
>      logdir = bb.data.getVar('LOG_DIR', d, True)

-- 
Joshua Lock
        Yocto Build System Monkey
        Intel Open Source Technology Centre



  reply	other threads:[~2011-05-13 17:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-13  6:59 [PATCH 0/2] Add checklicense task to get missing license text Mei Lei
2011-05-13  6:59 ` [PATCH 1/2] distro_check.py: Add a new function to reduce the repeat code Mei Lei
2011-05-13 17:13   ` Joshua Lock [this message]
2011-05-13  6:59 ` [PATCH 2/2] distrodata.bbclass: Add checklicense task Mei Lei
2011-05-13 17:13   ` Joshua Lock
2011-05-16 12:30     ` Mei, Lei

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=1305306808.2023.18.camel@scimitar \
    --to=josh@linux.intel.com \
    --cc=poky@yoctoproject.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.