2021-12-03 11:27:58 -05:00
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
import termcolor
|
|
|
|
|
|
|
|
colors = { "b" : "blue", "g" : "green", "s" : "cyan", "l" : "yellow" }
|
|
|
|
last = "white"
|
|
|
|
newline = False
|
2022-04-18 11:23:48 -04:00
|
|
|
status=0
|
2021-12-03 11:27:58 -05:00
|
|
|
|
|
|
|
text = ""
|
|
|
|
def print_text(color, attr=None):
|
|
|
|
global text
|
|
|
|
termcolor.cprint(text, color=color, attrs=[attr] if attr else None, end="")
|
|
|
|
text = ""
|
|
|
|
|
|
|
|
while c := sys.stdin.read(1):
|
|
|
|
text += c
|
|
|
|
if re.match("^mkdir: .* File exists\n$", text):
|
|
|
|
print_text("white", "dark")
|
|
|
|
elif re.match("^The .*? Failed!!\n$", text):
|
|
|
|
text = "\n" + text if newline else text
|
|
|
|
newline = False
|
|
|
|
print_text("red", "bold")
|
2022-04-18 11:23:48 -04:00
|
|
|
status=1
|
2021-12-03 11:27:58 -05:00
|
|
|
elif match := re.match("^./server -([bgsl]) .*?\n$", text):
|
|
|
|
print_text(colors[match.group(1)], None)
|
|
|
|
elif match := re.match("^Waiting for '([bgsl])' to finish...", text):
|
|
|
|
last = colors[match.group(1)]
|
|
|
|
newline = True
|
|
|
|
print_text(last, "bold")
|
|
|
|
elif match := re.match("^ Done: .*?\n$", text):
|
|
|
|
print_text(last, "bold")
|
|
|
|
newline = False
|
|
|
|
elif c == "\n":
|
|
|
|
if len(text) > 1:
|
|
|
|
print_text("white", "bold")
|
|
|
|
text = ""
|
2022-04-18 11:23:48 -04:00
|
|
|
|
|
|
|
sys.exit(status)
|