fixes in aero
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import sys,os
|
import sys,os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
import re,signal
|
import re,signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@@ -24,6 +26,9 @@ CLRLN = '\033[K'
|
|||||||
CLRBLN = '\033[1K'
|
CLRBLN = '\033[1K'
|
||||||
DOWN = '\033[1B'
|
DOWN = '\033[1B'
|
||||||
|
|
||||||
|
SORTCONVERT = lambda text: float(text) if is_number(text) else -1
|
||||||
|
SORTKEY = lambda key: SORTCONVERT(key[2][:-1])
|
||||||
|
|
||||||
def setup_options():
|
def setup_options():
|
||||||
''' Setup the command line options '''
|
''' Setup the command line options '''
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
@@ -34,12 +39,10 @@ Tool to clean up and colorize the output of Anduril.
|
|||||||
Example: anduril run yourscript.and | %(prog)s
|
Example: anduril run yourscript.and | %(prog)s
|
||||||
You can tap in to an existing log with:
|
You can tap in to an existing log with:
|
||||||
tail -f -n +0 log/_global | %(prog)s''',formatter_class=argparse.RawTextHelpFormatter)
|
tail -f -n +0 log/_global | %(prog)s''',formatter_class=argparse.RawTextHelpFormatter)
|
||||||
parser.add_argument("--time-stamp",'-t',action="store_true",dest="timestamp",default=False,
|
|
||||||
help="Print a timestamp on each line")
|
|
||||||
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("logfile",type=str,action="store",default="",nargs="?",
|
|
||||||
help="Log file to read, uses stdin automatically")
|
|
||||||
parser.add_argument("--version",action='version', version=VERSION)
|
parser.add_argument("--version",action='version', version=VERSION)
|
||||||
options=parser.parse_args()
|
options=parser.parse_args()
|
||||||
|
|
||||||
@@ -67,8 +70,7 @@ def colorize(string):
|
|||||||
string=color_match[c][0].sub(color_match[c][1],string)
|
string=color_match[c][0].sub(color_match[c][1],string)
|
||||||
return string
|
return string
|
||||||
|
|
||||||
SORTCONVERT = lambda text: float(text) if is_number(text) else -1
|
|
||||||
SORTKEY = lambda key: SORTCONVERT(key[2][:-1])
|
|
||||||
|
|
||||||
def count_running(string, stats):
|
def count_running(string, stats):
|
||||||
''' Counts the running executions '''
|
''' Counts the running executions '''
|
||||||
@@ -76,6 +78,7 @@ def count_running(string, stats):
|
|||||||
spl=[i.strip() for i in string.split('|')]
|
spl=[i.strip() for i in string.split('|')]
|
||||||
if len(spl)!=4:
|
if len(spl)!=4:
|
||||||
return stats
|
return stats
|
||||||
|
spl.append(datetime.now())
|
||||||
if spl[3] in stats['files']:
|
if spl[3] in stats['files']:
|
||||||
index=stats['files'].index(spl[3])
|
index=stats['files'].index(spl[3])
|
||||||
stats['running'][index]=spl
|
stats['running'][index]=spl
|
||||||
@@ -94,18 +97,24 @@ def remove_running(stats):
|
|||||||
''' Remove Done files '''
|
''' Remove Done files '''
|
||||||
if not stats['running']:
|
if not stats['running']:
|
||||||
return stats
|
return stats
|
||||||
|
# Remove Done/Fail older than 60sec
|
||||||
|
for e in enumerate(stats['running']):
|
||||||
|
if (datetime.now() - e[1][4] > timedelta(seconds=60)):
|
||||||
|
if e[1][2]=='Done' or e[1][2]=='Failed':
|
||||||
|
stats['running'].pop(e[0])
|
||||||
|
stats['files'].pop(e[0])
|
||||||
|
# Remove Done/Fail if there are too many:
|
||||||
if len(stats['running'])>(stats['size'][0]-3):
|
if len(stats['running'])>(stats['size'][0]-3):
|
||||||
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])
|
||||||
stats['files'].pop(e[0])
|
stats['files'].pop(e[0])
|
||||||
#remove just one failed
|
return stats
|
||||||
if len(stats['running'])>(stats['size'][0]-3):
|
|
||||||
for e in enumerate(stats['running']):
|
|
||||||
if e[1][2]=='Failed':
|
if e[1][2]=='Failed':
|
||||||
stats['running'].pop(e[0])
|
stats['running'].pop(e[0])
|
||||||
stats['files'].pop(e[0])
|
stats['files'].pop(e[0])
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
def is_number(s):
|
def is_number(s):
|
||||||
@@ -126,10 +135,9 @@ def str_short(s,stats):
|
|||||||
return sNew
|
return sNew
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
for e in range(2):
|
for e in range(2):
|
||||||
sys.stdout.write(pos(e+1,0)+CLRLN)
|
sys.stdout.write(pos(e+1,0)+CLRLN)
|
||||||
@@ -146,10 +154,10 @@ def print_stats(stats):
|
|||||||
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]-3-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)
|
||||||
sys.stdout.write(LOAD)
|
#sys.stdout.write(LOAD)
|
||||||
|
|
||||||
def human_time():
|
def human_time():
|
||||||
t=datetime.now().strftime("%I:%M:%S %p")
|
t=datetime.now().strftime("%I:%M:%S %p")
|
||||||
|
|||||||
Reference in New Issue
Block a user