opuntiaOS - an operating system targeting x86 and ARMv7
at master 46 lines 1.1 kB view raw
1import subprocess 2import sys 3import os 4from termcolor import colored 5import signal 6 7# verbose 8flag = "" 9if len(sys.argv) >= 2: 10 flag = sys.argv[1] 11 12process = subprocess.Popen( 13 "./run_tester.sh", stdout=subprocess.PIPE, preexec_fn=os.setpgrp) 14string = "" 15 16 17def process_string(string): 18 19 if flag == "verbose": 20 print(string) 21 22 if (string.startswith("[OK]")): 23 print(colored("ok ", color="green", attrs=[ 24 "bold"]), string.replace("$", "/")[5:]) 25 26 if (string.startswith("[MSG]")): 27 print(string[6:]) 28 29 if (string.startswith("[ALL TESTS PASSED]")): 30 print(colored(string, color="green", attrs=["bold"])) 31 os.killpg(os.getpgid(process.pid), signal.SIGTERM) 32 33 if (string.startswith("[FAILED]")): 34 print(colored("failed ", color="red", attrs=[ 35 "bold"]), string.replace("$", "/")[9:]) 36 os.killpg(os.getpgid(process.pid), signal.SIGTERM) 37 exit(1) 38 39 40for c in iter(lambda: process.stdout.read(1), b''): 41 letter = c.decode() 42 if letter == "\n": 43 process_string(string) 44 string = "" 45 else: 46 string += letter