36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
|
import sys
|
||
|
import re
|
||
|
import termcolor
|
||
|
|
||
|
colors = { "b" : "blue", "g" : "green", "s" : "cyan", "l" : "yellow" }
|
||
|
last = "white"
|
||
|
newline = False
|
||
|
|
||
|
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")
|
||
|
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 = ""
|