From af2032c460328136e630fc6f550c2e7d3d25c284 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Thu, 14 Jan 2016 15:15:04 +0100 Subject: [PATCH] change unit of FilesystemFillState to bytes since that was assumed in other code --- file_helpers.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/file_helpers.py b/file_helpers.py index 981cc80..11974f4 100644 --- a/file_helpers.py +++ b/file_helpers.py @@ -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() -- 1.7.1