From patchwork Thu Jul 26 09:39:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel,1/3] monitordisk: update check() to return a dict Date: Thu, 26 Jul 2012 09:39:06 -0000 From: Kang Kai X-Patchwork-Id: 33111 Message-Id: <69b3f0cb55fb28675248e000efc543caf0df608f.1343295453.git.kai.kang@windriver.com> To: Cc: bitbake-devel@lists.openembedded.org, Zhenfeng.Zhao@windriver.com Update function check() to return a dict to provide information about disk monitor. This could help UIs to show more detail information to end user. Signed-off-by: Kang Kai --- bitbake/lib/bb/monitordisk.py | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/bb/monitordisk.py b/bitbake/lib/bb/monitordisk.py index 9469193..971a291 100644 --- a/bitbake/lib/bb/monitordisk.py +++ b/bitbake/lib/bb/monitordisk.py @@ -176,6 +176,7 @@ class diskMonitor: def __init__(self, configuration): self.enableMonitor = False + self.data = {'terminate': False} BBDirs = configuration.getVar("BB_DISKMON_DIRS", True) or None if BBDirs: @@ -200,7 +201,11 @@ class diskMonitor: def check(self, rq): - """ Take action for the monitor """ + """ + Take action for the monitor. + Return True to tell cooker that runqueue is terminated by disk monitor. + This return value is useful for UIs such as Hob. + """ if self.enableMonitor: for dev in self.devDict: @@ -219,10 +224,14 @@ class diskMonitor: logger.error("No new tasks can be excuted since the disk space monitor action is \"STOPTASKS\"!") self.checked[dev] = True rq.finish_runqueue(False) + self.setData(dev, 'disk', freeSpace, self.devDict[dev][1]) + return self.data elif self.devDict[dev][0] == "ABORT" and not self.checked[dev]: logger.error("Immediately abort since the disk space monitor action is \"ABORT\"!") self.checked[dev] = True rq.finish_runqueue(True) + self.setData(dev, 'disk', freeSpace, self.devDict[dev][1]) + return self.data # The free inodes, float point number freeInode = st.f_favail @@ -237,8 +246,20 @@ class diskMonitor: logger.error("No new tasks can be excuted since the disk space monitor action is \"STOPTASKS\"!") self.checked[dev] = True rq.finish_runqueue(False) + self.setData(dev, 'inode', freeSpace, self.devDict[dev][1]) + return self.data elif self.devDict[dev][0] == "ABORT" and not self.checked[dev]: logger.error("Immediately abort since the disk space monitor action is \"ABORT\"!") self.checked[dev] = True rq.finish_runqueue(True) - return + self.setData(dev, 'inode', freeSpace, self.devDict[dev][1]) + return self.data + return self.data + + def setData(self, dev, type, free, mountPoint): + """ Set the class member data """ + self.data['terminated'] = True + self.data['dev'] = dev + self.data['type'] = type + self.data['freespace'] = free + self.data['mountpoint'] = mountPoint