added option for activities

This commit is contained in:
ville rantanen
2013-11-08 22:06:57 +02:00
parent 570dcc8ab4
commit 0ab24cc7c0

View File

@@ -42,6 +42,8 @@ You can tap in to an existing log with:
parser.add_argument("--no-colors",'--nc',action="store_false",dest="colors",default=True, parser.add_argument("--no-colors",'--nc',action="store_false",dest="colors",default=True,
help="Disable colored output") help="Disable colored output")
parser.add_argument("-a",action="store_false",dest="activities",default=True,
help="Disable activities output")
parser.add_argument("--version",action='version', version=VERSION) parser.add_argument("--version",action='version', version=VERSION)
options=parser.parse_args() options=parser.parse_args()
@@ -103,7 +105,7 @@ def remove_running(stats):
stats['running'].pop(e[0]) stats['running'].pop(e[0])
stats['files'].pop(e[0]) stats['files'].pop(e[0])
# Remove Done/Fail if there are too many: # Remove Done/Fail if there are too many:
if len(stats['running'])>(stats['size'][0]-3): if len(stats['running'])>(stats['size'][0]-6):
for e in enumerate(stats['running']): for e in enumerate(stats['running']):
if e[1][2]=='Done': if e[1][2]=='Done':
stats['running'].pop(e[0]) stats['running'].pop(e[0])
@@ -137,7 +139,10 @@ def str_short(s,stats):
def print_stats(stats): def print_stats(stats):
''' Prints logged errors, and the status line ''' ''' Prints logged errors, and the status line '''
#sys.stdout.write(SAVE) #sys.stdout.write(SAVE)
e=5 if options.activities:
e=5
else:
e=0
sys.stdout.write(pos(e+1,0)+"="*10+"AeroFS Transfers"+"="*10+" "+human_time()+CLRLN) sys.stdout.write(pos(e+1,0)+"="*10+"AeroFS Transfers"+"="*10+" "+human_time()+CLRLN)
if (stats['running']): if (stats['running']):
sys.stdout.write(pos(e+2,0)+"Last update: "+stats['running'][0][0]+CLRLN) sys.stdout.write(pos(e+2,0)+"Last update: "+stats['running'][0][0]+CLRLN)
@@ -150,7 +155,7 @@ def print_stats(stats):
colorize(ex[1][2].ljust(6)), colorize(ex[1][2].ljust(6)),
str_short(ex[1][3],stats)])+ str_short(ex[1][3],stats)])+
CLRLN) CLRLN)
for i in range(stats['size'][0]-3-len(stats['running'])): for i in range(stats['size'][0]-6-len(stats['running'])):
sys.stdout.write(pos(e+4+ex[0]+i,0)+" "+CLRLN) sys.stdout.write(pos(e+4+ex[0]+i,0)+" "+CLRLN)
sys.stdout.write(DOWN+CLRBLN+CLRLN) sys.stdout.write(DOWN+CLRBLN+CLRLN)
@@ -242,7 +247,7 @@ while 1:
if not line: if not line:
raise EndProgram raise EndProgram
if ( datetime.now() - stats['time'] > timedelta(seconds=30) ): if ( datetime.now() - stats['time'] > timedelta(seconds=30) ) and options.activities:
print_activities() print_activities()
stats['time'] = datetime.now() stats['time'] = datetime.now()