All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Lock <joshua.g.lock@linux.intel.com>
To: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>,
	 openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v3, 1/2] lib/oe/sdk: Add get_extra_sdk_info to reuse code in buildhistory
Date: Tue, 28 Mar 2017 11:59:02 +0100	[thread overview]
Message-ID: <1490698742.29806.1.camel@linux.intel.com> (raw)
In-Reply-To: <1490685341-9889-1-git-send-email-francisco.j.pedraza.gonzalez@intel.com>

On Tue, 2017-03-28 at 00:15 -0700, Francisco Pedraza wrote:
> This function is going to be used for generating the target and host
> manifest files packages for eSDK.
> [YOCTO #9038]
> 
> Signed-off-by: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.
> com>
> ---
>  meta/classes/buildhistory.bbclass | 16 ++++------------
>  meta/lib/oe/sdk.py                | 16 ++++++++++++++++
>  2 files changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/meta/classes/buildhistory.bbclass
> b/meta/classes/buildhistory.bbclass
> index 109b375..ab04db7 100644
> --- a/meta/classes/buildhistory.bbclass
> +++ b/meta/classes/buildhistory.bbclass
> @@ -554,25 +554,17 @@ END
>  python buildhistory_get_extra_sdkinfo() {
>      import operator
>      import math

I don't think we need to import math here anymore?

> +    # importing oe.sdk due package information req.

No need for this comment.

> +    from oe.sdk import get_extra_sdkinfo
>  
>      if d.getVar('BB_CURRENTTASK') == 'populate_sdk_ext' and \
>              "sdk" in (d.getVar('BUILDHISTORY_FEATURES') or
> "").split():
> -        tasksizes = {}
> -        filesizes = {}
> -        for root, _, files in
> os.walk(d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache')):
> -            for fn in files:
> -                if fn.endswith('.tgz'):
> -                    fsize =
> int(math.ceil(float(os.path.getsize(os.path.join(root, fn))) / 1024))
> -                    task = fn.rsplit(':', 1)[1].split('_',
> 1)[1].split('.')[0]
> -                    origtotal = tasksizes.get(task, 0)
> -                    tasksizes[task] = origtotal + fsize
> -                    filesizes[fn] = fsize
>          with open(d.expand('${BUILDHISTORY_DIR_SDK}/sstate-package-
> sizes.txt'), 'w') as f:
> -            filesizes_sorted = sorted(filesizes.items(),
> key=operator.itemgetter(1, 0), reverse=True)
> +            filesizes_sorted =
> sorted(extra_info['filesizes'].items(), key=operator.itemgetter(1,
> 0), reverse=True)
>              for fn, size in filesizes_sorted:
>                  f.write('%10d KiB %s\n' % (size, fn))
>          with open(d.expand('${BUILDHISTORY_DIR_SDK}/sstate-task-
> sizes.txt'), 'w') as f:
> -            tasksizes_sorted = sorted(tasksizes.items(),
> key=operator.itemgetter(1, 0), reverse=True)
> +             tasksizes_sorted =
> sorted(extra_info['tasksizes'].items(), key=operator.itemgetter(1,
> 0), reverse=True)

It looks like the indentation changes here?

>              for task, size in tasksizes_sorted:
>                  f.write('%10d KiB %s\n' % (size, task))
>  }
> diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py
> index deb823b..d101bf0 100644
> --- a/meta/lib/oe/sdk.py
> +++ b/meta/lib/oe/sdk.py
> @@ -372,5 +372,21 @@ def populate_sdk(d, manifest_dir=None):
>      os.environ.clear()
>      os.environ.update(env_bkp)
>  
> +def get_extra_sdk_info(sstate_dir):
> +    import operator

I don't think we need operator here?

A docstring for this function would be nice.

> +    import math
> +
> +    extra_info = {}
> +    extra_info['tasksizes']
> +    for root, _, files in os.walk(sstate_dir):
> +        for fn in files:
> +            if fn.endswith('.tgz'):
> +                fsize =
> int(math.ceil(float(os.path.getsize(os.path.join(root, fn))) / 1024))
> +                task =
> fn.rsplit(':',1)[1].split('_',1)[1].split(',')[0]
> +                origtotal = extra_info['tasksizes'].get(task, 0)
> +                extra_info['tasksizes'][task] = origtotal + fsize
> +                extra_info['filesizes'][fn] = fsize
> +    return extra_info 
> +
>  if __name__ == "__main__":
>      pass
> -- 
> 1.8.3.1
> 


      parent reply	other threads:[~2017-03-28 10:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28  7:15 [PATCH v3, 1/2] lib/oe/sdk: Add get_extra_sdk_info to reuse code in buildhistory Francisco Pedraza
2017-03-28  7:15 ` [PATCH v3, 2/2] meta/classes/populate_sdk: Adds support for generating eSDK manifest files Francisco Pedraza
2017-03-28 10:59 ` Joshua Lock [this message]

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=1490698742.29806.1.camel@linux.intel.com \
    --to=joshua.g.lock@linux.intel.com \
    --cc=francisco.j.pedraza.gonzalez@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.