Patchwork [bitbake-devel,1/3] monitordisk: update check() to return a dict

login
register
mail settings
Submitter Kang Kai
Date July 26, 2012, 9:39 a.m.
Message ID <69b3f0cb55fb28675248e000efc543caf0df608f.1343295453.git.kai.kang@windriver.com>
Download mbox | patch
Permalink /patch/33111/
State New
Headers show

Comments

Kang Kai - July 26, 2012, 9:39 a.m.
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@windriver.com>
---
 bitbake/lib/bb/monitordisk.py |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

Patch

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