change unit of FilesystemFillState to bytes since that was assumed in other code
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 14 Jan 2016 14:15:04 +0000 (15:15 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 14 Jan 2016 14:15:04 +0000 (15:15 +0100)
file_helpers.py

index 981cc80..11974f4 100644 (file)
@@ -40,6 +40,7 @@ def cd(path):
 
 
 DF_CMD = ['/usr/bin/df', '--no-sync', '--portability']
+DF_SIZE_UNIT = 1024
 
 class FilesystemFillState:
     """ representation of 1 line of the 'df' command
@@ -48,6 +49,7 @@ class FilesystemFillState:
 
     Note that only apprixomately capacity == used/size
      and that only approximately used + available == size
+     and that all sizes are in bytes
     """
 
     def __init__(self):
@@ -129,10 +131,12 @@ def get_filesystem_fill_states():
     for line in out[1:]:
         stats = FilesystemFillState()
         stats.name = line[ : separator_cols[0]].strip()
-        stats.size = int(line[separator_cols[0] : separator_cols[1]].strip())
-        stats.used = int(line[separator_cols[1] : separator_cols[2]].strip())
+        stats.size = int(line[separator_cols[0] : separator_cols[1]].strip()) \
+                     * DF_SIZE_UNIT
+        stats.used = int(line[separator_cols[1] : separator_cols[2]].strip()) \
+                     * DF_SIZE_UNIT
         stats.available = int(line[separator_cols[2] : separator_cols[3]]\
-                              .strip())
+                              .strip()) * DF_SIZE_UNIT
         stats.capacity = int(line[separator_cols[3] : separator_cols[4]]\
                              .strip()[:-1])
         stats.mount_point = line[separator_cols[4] : ].strip()