Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>,
	"Flanagan, Elizabeth" <elizabeth.flanagan@intel.com>
Subject: [PATCH 3/7] buildstats: Clean up e.data and bb.data references
Date: Thu, 17 Dec 2015 14:54:08 +0000	[thread overview]
Message-ID: <1450364048.13505.207.camel@linuxfoundation.org> (raw)

Rather than bb.data and e.data, cleanup to use 'd' and match the
standard coding style.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 73e0b2a..4fa6981 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -20,7 +20,7 @@ def get_cputime():
         fields = f.readline().rstrip().split()[1:]
     return sum(int(field) for field in fields)
 
-def set_timedata(var, data, server_time=None):
+def set_timedata(var, d, server_time=None):
     import time
     if server_time:
         time = server_time
@@ -28,11 +28,11 @@ def set_timedata(var, data, server_time=None):
         time = time.time()
     cputime = get_cputime()
     proctime = get_process_cputime(os.getpid())
-    data.setVar(var, (time, cputime, proctime))
+    d.setVar(var, (time, cputime, proctime))
 
-def get_timedata(var, data, server_time=None):
+def get_timedata(var, d, server_time=None):
     import time
-    timedata = data.getVar(var, False)
+    timedata = d.getVar(var, False)
     if timedata is None:
         return
     oldtime, oldcpu, oldproc = timedata
@@ -49,15 +49,15 @@ def get_timedata(var, data, server_time=None):
         cpuperc = None
     return timediff, cpuperc
 
-def write_task_data(status, logfile, e):
-    bn = e.data.getVar('BUILDNAME', True)
-    bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
+def write_task_data(status, logfile, e, d):
+    bn = d.getVar('BUILDNAME', True)
+    bsdir = os.path.join(d.getVar('BUILDSTATS_BASE', True), bn)
     with open(os.path.join(logfile), "a") as f:
-        timedata = get_timedata("__timedata_task", e.data, e.time)
+        timedata = get_timedata("__timedata_task", d, e.time)
         if timedata:
             elapsedtime, cpu = timedata
-            f.write(bb.data.expand("${PF}: %s: Elapsed time: %0.2f seconds \n" %
-                                    (e.task, elapsedtime), e.data))
+            f.write(d.expand("${PF}: %s: Elapsed time: %0.2f seconds \n" %
+                                    (e.task, elapsedtime)))
             if cpu:
                 f.write("CPU usage: %0.1f%% \n" % cpu)
         if status is "passed":
@@ -69,12 +69,11 @@ def write_task_data(status, logfile, e):
 python run_buildstats () {
     import bb.build
     import bb.event
-    import bb.data
     import time, subprocess, platform
 
-    bn = e.data.getVar('BUILDNAME', True)
-    bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
-    taskdir = os.path.join(bsdir, e.data.getVar('PF', True))
+    bn = d.getVar('BUILDNAME', True)
+    bsdir = os.path.join(d.getVar('BUILDSTATS_BASE', True), bn)
+    taskdir = os.path.join(bsdir, d.getVar('PF', True))
 
     if isinstance(e, bb.event.BuildStarted):
         ########################################################################
@@ -82,7 +81,7 @@ python run_buildstats () {
         # set the buildname
         ########################################################################
         bb.utils.mkdirhier(bsdir)
-        set_timedata("__timedata_build", e.data)
+        set_timedata("__timedata_build", d)
         build_time = os.path.join(bsdir, "build_stats")
         # write start of build into build_time
         with open(build_time, "a") as f:
@@ -100,7 +99,7 @@ python run_buildstats () {
             ########################################################################
             # Write build statistics for the build
             ########################################################################
-            timedata = get_timedata("__timedata_build", e.data)
+            timedata = get_timedata("__timedata_build", d)
             if timedata:
                 time, cpu = timedata
                 # write end of build and cpu used into build_time
@@ -109,7 +108,7 @@ python run_buildstats () {
                     f.write("CPU usage: %0.1f%% \n" % cpu)
 
     if isinstance(e, bb.build.TaskStarted):
-        set_timedata("__timedata_task", e.data, e.time)
+        set_timedata("__timedata_task", d, e.time)
         bb.utils.mkdirhier(taskdir)
         # write into the task event file the name and start time
         with open(os.path.join(taskdir, e.task), "a") as f:
@@ -117,16 +116,16 @@ python run_buildstats () {
             f.write("Started: %0.2f \n" % e.time)
 
     elif isinstance(e, bb.build.TaskSucceeded):
-        write_task_data("passed", os.path.join(taskdir, e.task), e)
+        write_task_data("passed", os.path.join(taskdir, e.task), e, d)
         if e.task == "do_rootfs":
             bs = os.path.join(bsdir, "build_stats")
             with open(bs, "a") as f:
-                rootfs = e.data.getVar('IMAGE_ROOTFS', True)
+                rootfs = d.getVar('IMAGE_ROOTFS', True)
                 rootfs_size = subprocess.Popen(["du", "-sh", rootfs], stdout=subprocess.PIPE).stdout.read()
                 f.write("Uncompressed Rootfs size: %s" % rootfs_size)
 
     elif isinstance(e, bb.build.TaskFailed):
-        write_task_data("failed", os.path.join(taskdir, e.task), e)
+        write_task_data("failed", os.path.join(taskdir, e.task), e, d)
         ########################################################################
         # Lets make things easier and tell people where the build failed in
         # build_status. We do this here because BuildCompleted triggers no
@@ -134,7 +133,7 @@ python run_buildstats () {
         ########################################################################
         build_status = os.path.join(bsdir, "build_stats")
         with open(build_status, "a") as f:
-            f.write(e.data.expand("Failed at: ${PF} at task: %s \n" % e.task))
+            f.write(d.expand("Failed at: ${PF} at task: %s \n" % e.task))
 }
 
 addhandler run_buildstats




                 reply	other threads:[~2015-12-17 14:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1450364048.13505.207.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=elizabeth.flanagan@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