[bitbake-devel] [PATCH 1/3] monitordisk: update check() to return a dict
Kang Kai
kai.kang at windriver.com
Thu Jul 26 09:39:06 UTC 2012
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 <kai.kang at windriver.com>
---
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
--
1.7.5.4
More information about the bitbake-devel
mailing list