better oneshot printing

This commit is contained in:
ville rantanen
2014-03-27 12:31:35 +02:00
parent e16bb8659f
commit 03349602b5

View File

@@ -173,7 +173,7 @@ def print_stats_once(stats):
return return
sys.stdout.write(" Total Used Use% Free"+CLRLN+'\n') sys.stdout.write(" Total Used Use% Free"+CLRLN+'\n')
for ex in enumerate(stats['running']): for ex in enumerate(stats['running']):
sys.stdout.write('('+str(ex[0]+1).rjust(2)+') '+ sys.stdout.write(
' '.join([ ' '.join([
human_size(ex[1][6]).rjust(8), human_size(ex[1][6]).rjust(8),
human_size(ex[1][6]-ex[1][0]).rjust(10), human_size(ex[1][6]-ex[1][0]).rjust(10),
@@ -182,7 +182,7 @@ def print_stats_once(stats):
ex[1][2], ex[1][2],
"("+ex[1][5]+")"])+ "("+ex[1][5]+")"])+
CLRLN+'\n') CLRLN+'\n')
sys.stdout.write('Tot: '+ sys.stdout.write(
' '.join([ ' '.join([
human_size(stats['totals'][1]).rjust(8), human_size(stats['totals'][1]).rjust(8),
human_size(stats['totals'][1]-stats['totals'][0]).rjust(10), ' ', human_size(stats['totals'][1]-stats['totals'][0]).rjust(10), ' ',
@@ -193,14 +193,16 @@ def print_stats_once(stats):
def colorize_usage(string): def colorize_usage(string):
''' colorizes the usage string ''' ''' colorizes the usage string '''
# string length indicates value <10
if len(string)<3: if len(string)<3:
return c((S,G))+" "+string+c((E)) return c((S,G))+" "+string+c((E))
# string lenght indicates 100%
if len(string)==4: if len(string)==4:
return c((S,R))+string+c((E)) return c((S,R))+string+c((E))
tens=int(string[0]) usage=int(string[0:2])
if tens==9: if usage>95:
return c((S,R))+" "+string+c((E)) return c((S,R))+" "+string+c((E))
if tens<7: if usage<80:
return c((S,G))+" "+string+c((E)) return c((S,G))+" "+string+c((E))
return c((S,Y))+" "+string+c((E)) return c((S,Y))+" "+string+c((E))