From fa14a5485bf46868f0295e514a06e96c63c1f672 Mon Sep 17 00:00:00 2001 From: ruppert Date: Wed, 12 Sep 2012 12:31:59 +0000 Subject: [PATCH] ENH: uses psutil instead of sigar now --- invesalius/utils.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/invesalius/utils.py b/invesalius/utils.py index 0e05b20..6f22531 100755 --- a/invesalius/utils.py +++ b/invesalius/utils.py @@ -18,7 +18,6 @@ #-------------------------------------------------------------------------- import platform import time -import sigar import sys import re import locale @@ -215,14 +214,21 @@ def calculate_resizing_tofitmemory(x_size,y_size,n_slices,byte): """ imagesize = x_size * y_size * n_slices * byte * 28 - sg = sigar.open() - ram_free = sg.mem().actual_free() - ram_total = sg.mem().actual_free() - swap_free = sg.swap().free() - sg.close() - - print "RAM FREE", ram_free - print "RAM_TOTAL", ram_total + # USING LIBSIGAR + #import sigar + #sg = sigar.open() + #ram_free = sg.mem().actual_free() + #ram_total = sg.mem().actual_free() + #swap_free = sg.swap().free() + #sg.close() + + # USING PSUTIL + import psutil + ram_free = psutil.phymem_usage().free + psutil.cached_phymem() + psutil.phymem_buffers() + ram_total = psutil.phymem_usage().total + swap_free = psutil.virtmem_usage().free + print "RAM_FREE=", ram_free + print "RAM_TOTAL=", ram_total if (sys.platform == 'win32'): if (platform.architecture()[0] == '32bit'): -- libgit2 0.21.2