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