public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH 2/4] buildstats: Fix bbclass to work with ISAR
Date: Mon, 13 Sep 2021 17:03:53 +0200	[thread overview]
Message-ID: <20210913150355.9973-3-ubely@ilbers.de> (raw)
In-Reply-To: <20210913150355.9973-1-ubely@ilbers.de>

1. rootfs may be empty that causes exception.
2. sudo required to calculate rootfs disk usage.
3. sys.path modification to make meta/lib available.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 meta/classes/buildstats.bbclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 0de6052..e2db8f6 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -242,9 +242,9 @@ python run_buildstats () {
             bs = os.path.join(bsdir, "build_stats")
             with open(bs, "a") as f:
                 rootfs = d.getVar('IMAGE_ROOTFS')
-                if os.path.isdir(rootfs):
+                if rootfs and os.path.isdir(rootfs):
                     try:
-                        rootfs_size = subprocess.check_output(["du", "-sh", rootfs],
+                        rootfs_size = subprocess.check_output(["sudo", "du", "-sh", rootfs],
                                 stderr=subprocess.STDOUT).decode('utf-8')
                         f.write("Uncompressed Rootfs size: %s" % rootfs_size)
                     except subprocess.CalledProcessError as err:
@@ -270,6 +270,9 @@ addhandler run_buildstats
 run_buildstats[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted bb.event.HeartbeatEvent bb.build.TaskStarted bb.build.TaskSucceeded bb.build.TaskFailed"
 
 python runqueue_stats () {
+    import sys
+    oe_lib_path = os.path.join(d.getVar('LAYERDIR_core'), 'lib')
+    sys.path.insert(0, oe_lib_path)
     import buildstats
     from bb import event, runqueue
     # We should not record any samples before the first task has started,
-- 
2.20.1


  parent reply	other threads:[~2021-09-13 15:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 15:03 [PATCH 0/4] Use buildstats from OE to generate build charts Uladzimir Bely
2021-09-13 15:03 ` [PATCH 1/4] buildstats: Borrow buildstats and pybootchartgui from OE Uladzimir Bely
2021-09-13 15:03 ` Uladzimir Bely [this message]
2021-09-13 15:03 ` [PATCH 3/4] buildstats: Manage buildstats via USER_CLASSES variable Uladzimir Bely
2021-09-13 15:03 ` [PATCH 4/4] doc: Add buildstats section in user manual Uladzimir Bely
2021-09-13 18:23 ` [PATCH 0/4] Use buildstats from OE to generate build charts Jan Kiszka
2021-09-14  7:18   ` Uladzimir Bely
2021-09-14 11:23     ` Jan Kiszka

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=20210913150355.9973-3-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /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