bitbake: monitordisk.py: minor code and comment cleanup
There's no need to encode and decode the hash key as a single string, a tuple works just fine. Iterating over entries can be written more concisely. Entries in the stat results are integers, not floating point values. (Bitbake rev: 3c943e989964382c0b819d92de26a0c914ebed33) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
ad20ee9feb
commit
091ebb8665
|
@ -129,7 +129,7 @@ def getDiskData(BBDirs, configuration):
|
||||||
bb.utils.mkdirhier(path)
|
bb.utils.mkdirhier(path)
|
||||||
dev = getMountedDev(path)
|
dev = getMountedDev(path)
|
||||||
# Use path/action as the key
|
# Use path/action as the key
|
||||||
devDict[os.path.join(path, action)] = [dev, minSpace, minInode]
|
devDict[(path, action)] = [dev, minSpace, minInode]
|
||||||
|
|
||||||
return devDict
|
return devDict
|
||||||
|
|
||||||
|
@ -205,16 +205,13 @@ class diskMonitor:
|
||||||
""" Take action for the monitor """
|
""" Take action for the monitor """
|
||||||
|
|
||||||
if self.enableMonitor:
|
if self.enableMonitor:
|
||||||
for k in self.devDict:
|
for k, attributes in self.devDict.items():
|
||||||
path = os.path.dirname(k)
|
path, action = k
|
||||||
action = os.path.basename(k)
|
dev, minSpace, minInode = attributes
|
||||||
dev = self.devDict[k][0]
|
|
||||||
minSpace = self.devDict[k][1]
|
|
||||||
minInode = self.devDict[k][2]
|
|
||||||
|
|
||||||
st = os.statvfs(path)
|
st = os.statvfs(path)
|
||||||
|
|
||||||
# The free space, float point number
|
# The available free space, integer number
|
||||||
freeSpace = st.f_bavail * st.f_frsize
|
freeSpace = st.f_bavail * st.f_frsize
|
||||||
|
|
||||||
if minSpace and freeSpace < minSpace:
|
if minSpace and freeSpace < minSpace:
|
||||||
|
@ -235,7 +232,7 @@ class diskMonitor:
|
||||||
rq.finish_runqueue(True)
|
rq.finish_runqueue(True)
|
||||||
bb.event.fire(bb.event.DiskFull(dev, 'disk', freeSpace, path), self.configuration)
|
bb.event.fire(bb.event.DiskFull(dev, 'disk', freeSpace, path), self.configuration)
|
||||||
|
|
||||||
# The free inodes, float point number
|
# The free inodes, integer number
|
||||||
freeInode = st.f_favail
|
freeInode = st.f_favail
|
||||||
|
|
||||||
if minInode and freeInode < minInode:
|
if minInode and freeInode < minInode:
|
||||||
|
|
Loading…
Reference in New Issue