Patchwork [bitbake-devel,1/2] monitordisk: fire event DISKFULL when terminate build

login
register
mail settings
Submitter Kang Kai
Date July 27, 2012, 8:38 a.m.
Message ID <2ec1cda758940ef838a5d272a2418951658f50d2.1343378110.git.kai.kang@windriver.com>
Download mbox | patch
Permalink /patch/33179/
State New
Headers show

Comments

Kang Kai - July 27, 2012, 8:38 a.m.
Part of [Yocto #2168]

Add a event DiskFull to descript the termination by disk monitor.

Update check() to fire the event DiskFull when terminates the build.
This could help UIs to deal this scenario and show more information to
end user.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 bitbake/lib/bb/event.py       |    8 ++++++++
 bitbake/lib/bb/monitordisk.py |    5 +++++
 2 files changed, 13 insertions(+), 0 deletions(-)

Patch

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 1116c0a..20923b5 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -312,6 +312,14 @@  class BuildCompleted(BuildBase, OperationCompleted):
             OperationCompleted.__init__(self, total, "Building Failed")
         BuildBase.__init__(self, n, p, failures)
 
+class DiskFull(Event):
+    """Disk full case build aborted"""
+    def __init__(self, dev, type, freespace, mountpoint):
+        Event.__init__(self)
+        self._dev = dev
+        self._type = type
+        self._free = freespace
+        self._mountpoint = mountpoint
 
 class NoProvider(Event):
     """No Provider for an Event"""
diff --git a/bitbake/lib/bb/monitordisk.py b/bitbake/lib/bb/monitordisk.py
index 9469193..2bd4881 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.configuration = configuration
 
         BBDirs = configuration.getVar("BB_DISKMON_DIRS", True) or None
         if BBDirs:
@@ -219,10 +220,12 @@  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)
+                        bb.event.fire(bb.event.DiskFull(dev, 'disk', freeSpace, self.devDict[dev][1]), self.configuration)
                     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)
+                        bb.event.fire(bb.event.DiskFull(dev, 'disk', freeSpace, self.devDict[dev][1]), self.configuration)
 
                 # The free inodes, float point number
                 freeInode = st.f_favail
@@ -237,8 +240,10 @@  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)
+                        bb.event.fire(bb.event.DiskFull(dev, 'inode', freeSpace, self.devDict[dev][1]), self.configuration)
                     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)
+                        bb.event.fire(bb.event.DiskFull(dev, 'inode', freeSpace, self.devDict[dev][1]), self.configuration)
         return