summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurie Clark-Michalek <bluepeppers@archlinux.us>2010-11-17 21:58:05 +0000
committerLaurie Clark-Michalek <bluepeppers@archlinux.us>2010-11-17 21:58:05 +0000
commitf45812e24169185e2b0589e98612f04ff8ef4fa8 (patch)
tree4b0bce6f7339aaf5a7babd6634988e23badf6bd7
parent96c455dac0a20d13fe27b649f6e34a14b87c2c2c (diff)
Added fix to coloring of File system output.
Added conversion table to convert between size chars ('M', 'G', 'k' etc) and int.
-rwxr-xr-xarchey314
1 files changed, 11 insertions, 3 deletions
diff --git a/archey3 b/archey3
index 713be84..6658b20 100755
--- a/archey3
+++ b/archey3
@@ -188,6 +188,14 @@ class display(object):
class fsDisplay(display):
command_line = "df -TPh {arg1}"
+ conversions = {
+ 'M': 1 * 10 ** 6,
+ 'K': 1 * 10 ** 3,
+ 'G': 1 * 10 ** 9,
+ 'T': 1 * 10 ** 12,
+ 'P': 1 * 10 ** 15,
+ }
+
def __init__(self, path='/', parent=None):
self.arg1 = path
self._parent = parent
@@ -201,9 +209,9 @@ class fsDisplay(display):
mount = '/root' if self.arg1 == '/' else self.arg1
title = mount.split('/')[-1].title() + " FS"
try:
- used_ = ''.join(c for c in used if c.isdigit())
- total_ = ''.join(c for c in total if c.isdigit())
- persentage = (int(used_)/int(total_) * 100)
+ used_ = int(used[:-1]) * self.conversions[used[-1]]
+ total_ = int(total[:-1]) * self.conversions[total[-1]]
+ persentage = used_ / total_ * 100
except:
pass
else: