diff options
author | Nicolas Hennion <nicolas@nicolargo.com> | 2012-12-26 22:30:53 +0100 |
---|---|---|
committer | Nicolas Hennion <nicolas@nicolargo.com> | 2012-12-26 22:30:53 +0100 |
commit | ccb198ea357bc0e00fcf8b4f607b4d69dbbb018f (patch) | |
tree | 7c4c04ff358dbb6ec41d6d636223f20063cf7dfe | |
parent | e60cb2c139e664497d65a1378ab50e7c53d721ac (diff) |
Little hack for a PsUtil issue #152
-rwxr-xr-x | glances/glances.py | 20 | ||||
-rwxr-xr-x | glances/unitest.py | 4 |
2 files changed, 17 insertions, 7 deletions
diff --git a/glances/glances.py b/glances/glances.py index d03c2a0a..d6c9a767 100755 --- a/glances/glances.py +++ b/glances/glances.py @@ -747,11 +747,16 @@ class GlancesStats: 'cached': cached} # Swap - virtmem = psutil.swap_memory() - self.memswap = {'total': virtmem.total, - 'used': virtmem.used, - 'free': virtmem.free, - 'percent': virtmem.percent} + # try... is an hack for issue #152 + try: + virtmem = psutil.swap_memory() + except: + self.memswap = {} + else: + self.memswap = {'total': virtmem.total, + 'used': virtmem.used, + 'free': virtmem.free, + 'percent': virtmem.percent} else: # psutil < 0.6 # RAM @@ -1709,7 +1714,7 @@ class glancesScreen: def displayMem(self, mem, memswap, proclist, offset_x=0): # Memory - if not mem or not memswap: + if not mem: return 0 screen_x = self.screen.getmaxyx()[1] screen_y = self.screen.getmaxyx()[0] @@ -1806,6 +1811,9 @@ class glancesScreen: # If space is NOT available then mind the gap... offset_x -= extblocksize + if not memswap: + return 0 + # Swap self.term_window.addnstr(self.mem_y, self.mem_x + offset_x + 32, _("Swap"), 4, diff --git a/glances/unitest.py b/glances/unitest.py index 97ccdff4..644a96f7 100755 --- a/glances/unitest.py +++ b/glances/unitest.py @@ -25,6 +25,9 @@ import unittest import multiprocessing +import os +import signal +import time import glances @@ -115,6 +118,5 @@ class TestGlancesStat(unittest.TestCase): self.assertTrue(type(sensors) == list) #~ self.assertTrue(len(sensors) > 0) - if __name__ == '__main__': unittest.main() |