1
0
Fork 0

compact motd memory, check if psutil is installed

This commit is contained in:
Massaki Archambault 2018-05-14 15:32:55 -04:00
parent 45161059d2
commit d779d0fdba
1 changed files with 17 additions and 10 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import math import math
import psutil
import shutil import shutil
import sys import sys
import os import os
@ -9,6 +8,11 @@ import re
from subprocess import check_call, DEVNULL, CalledProcessError from subprocess import check_call, DEVNULL, CalledProcessError
try:
import psutil
except:
pass
try: try:
from pyfiglet import figlet_format from pyfiglet import figlet_format
except ImportError: except ImportError:
@ -106,15 +110,18 @@ def print_services():
def print_mem(): def print_mem():
print('Memory:') try:
memory = psutil.virtual_memory() memory = psutil.virtual_memory()
Termutils.print_padded('{:.2f}G used {:6.2f}G free {:6.2f}G total'.format( print('{:<18} {:6.2f}G used {:6.2f}G free {:6.2f}G total'.format(
to_gb(memory.used), 'Memory:',
to_gb(memory.free), to_gb(memory.used),
to_gb(memory.total) to_gb(memory.free),
)) to_gb(memory.total)
Termutils.print_progress_bar(memory.used / memory.total) ))
print('') Termutils.print_progress_bar(memory.used / memory.total)
print('')
except NameError:
pass
def print_fs(): def print_fs():