Commit fa14a5485bf46868f0295e514a06e96c63c1f672

Authored by ruppert
1 parent a19e3aad

ENH: uses psutil instead of sigar now

Showing 1 changed file with 15 additions and 9 deletions   Show diff stats
invesalius/utils.py
... ... @@ -18,7 +18,6 @@
18 18 #--------------------------------------------------------------------------
19 19 import platform
20 20 import time
21   -import sigar
22 21 import sys
23 22 import re
24 23 import locale
... ... @@ -215,14 +214,21 @@ def calculate_resizing_tofitmemory(x_size,y_size,n_slices,byte):
215 214 """
216 215 imagesize = x_size * y_size * n_slices * byte * 28
217 216  
218   - sg = sigar.open()
219   - ram_free = sg.mem().actual_free()
220   - ram_total = sg.mem().actual_free()
221   - swap_free = sg.swap().free()
222   - sg.close()
223   -
224   - print "RAM FREE", ram_free
225   - print "RAM_TOTAL", ram_total
  217 + # USING LIBSIGAR
  218 + #import sigar
  219 + #sg = sigar.open()
  220 + #ram_free = sg.mem().actual_free()
  221 + #ram_total = sg.mem().actual_free()
  222 + #swap_free = sg.swap().free()
  223 + #sg.close()
  224 +
  225 + # USING PSUTIL
  226 + import psutil
  227 + ram_free = psutil.phymem_usage().free + psutil.cached_phymem() + psutil.phymem_buffers()
  228 + ram_total = psutil.phymem_usage().total
  229 + swap_free = psutil.virtmem_usage().free
  230 + print "RAM_FREE=", ram_free
  231 + print "RAM_TOTAL=", ram_total
226 232  
227 233 if (sys.platform == 'win32'):
228 234 if (platform.architecture()[0] == '32bit'):
... ...