diff --git a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py index 3544ee9488550..e9ce275bbbbda 100755 --- a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py +++ b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py @@ -457,6 +457,8 @@ def stepOrIndex(s): opt.overWrite=eval(opt.overWrite) if opt.interactive: import cmd + from colorama import Fore, Style + from os import isatty class TheMatrix(cmd.Cmd): intro = "Welcome to the Matrix (? for help)" @@ -486,6 +488,12 @@ def do_exit(self, arg): def default(self, inp): if inp == 'x' or inp == 'q': return self.do_exit(inp) + else: + is_pipe = not isatty(sys.stdin.fileno()) + print(Fore.RED + "Error: " + Fore.RESET + "unrecognized command.") + # Quit only if given a piped command. + if is_pipe: + sys.exit(1) def help_predefined(self): print("\n".join(["predefined [predef1 [...]]\n", @@ -509,7 +517,7 @@ def do_predefined(self, arg): else: print("Unknown Set: %s" % w) else: - print(predefinedSet.keys()) + print("[ " + Fore.RED + ", ".join([str(k) for k in predefinedSet.keys()]) + Fore.RESET + " ]") def help_showWorkflow(self): print("\n".join(["showWorkflow [workflow1 [...]]\n", @@ -526,7 +534,8 @@ def do_showWorkflow(self, arg): if arg == '': print("Available workflows:") for k in self.matrices_.keys(): - print(k) + print(Fore.RED + Style.BRIGHT + k) + print(Style.RESET_ALL) else: selected = arg.split() for k in selected: @@ -534,9 +543,9 @@ def do_showWorkflow(self, arg): print("Unknown workflow %s: skipping" % k) else: for wfl in self.matrices_[k].workFlows: - wfName, stepNames = wfl.nameId.split('+',1) - print("%s %s %s" % (wfl.numId, wfName, stepNames)) - print("%s contains %d workflows" % (k, len(self.matrices_[k].workFlows))) + print("%s %s" % (Fore.BLUE + str(wfl.numId) + Fore.RESET, + Fore.GREEN + wfl.nameId + Fore.RESET)) + print("%s contains %d workflows" % (Fore.RED + k + Fore.RESET, len(self.matrices_[k].workFlows))) def help_searchInWorkflow(self): print("\n".join(["searchInWorkflow wfl_name search_regexp\n", @@ -566,11 +575,12 @@ def do_searchInWorkflow(self, arg): return counter = 0 for wfl in self.matrices_[args[0]].workFlows: - wfName, stepNames = wfl.nameId.split('+',1) - if re.match(pattern, wfName) or re.match(pattern, stepNames): - print("%s %s %s" % (wfl.numId, wfName, stepNames)) - counter += 1 - print("Found %d compatible workflows inside %s" % (counter, args[0])) + if re.match(pattern, wfl.nameId): + print("%s %s" % (Fore.BLUE + str(wfl.numId) + Fore.RESET, + Fore.GREEN + wfl.nameId + Fore.RESET)) + counter +=1 + print("Found %s compatible workflows inside %s" % (Fore.RED + str(counter) + Fore.RESET, + Fore.YELLOW + str(args[0])) + Fore.RESET) def help_search(self): print("\n".join(["search search_regexp\n", @@ -595,19 +605,19 @@ def do_dumpWorkflowId(self, arg): print("dumpWorkflowId [wfl-id1 [...]]") return - fmt = "[%d]: %s\n" + fmt = "[%s]: %s\n" maxLen = 100 for wflid in wflids: dump = True for key, mrd in self.matrices_.items(): for wfl in mrd.workFlows: if wfl.numId == float(wflid): - wfName, stepNames = wfl.nameId.split('+',1) if dump: dump = False - print(wfl.numId, stepNames) + print(Fore.GREEN + str(wfl.numId) + Fore.RESET + " " + Fore.YELLOW + wfl.nameId + Fore.RESET) for i,s in enumerate(wfl.cmds): - print(fmt % (i+1, (str(s)+' '))) + print(fmt % (Fore.RED + str(i+1) + Fore.RESET, + (str(s)+' '))) print("\nWorkflow found in %s." % key) else: print("Workflow also found in %s." % key) diff --git a/Configuration/PyReleaseValidation/test/BuildFile.xml b/Configuration/PyReleaseValidation/test/BuildFile.xml index 6fa7c3e401898..a10e105995cbc 100644 --- a/Configuration/PyReleaseValidation/test/BuildFile.xml +++ b/Configuration/PyReleaseValidation/test/BuildFile.xml @@ -1,3 +1,6 @@ + + + diff --git a/Configuration/PyReleaseValidation/test/test-runTheMatrix_interactive.sh b/Configuration/PyReleaseValidation/test/test-runTheMatrix_interactive.sh new file mode 100755 index 0000000000000..d995c64e2eafd --- /dev/null +++ b/Configuration/PyReleaseValidation/test/test-runTheMatrix_interactive.sh @@ -0,0 +1,10 @@ +#!/bin/bash -e + +echo 'help' | runTheMatrix.py --interactive || exit 1 +echo 'predefined' | runTheMatrix.py --interactive || exit 1 +echo 'showWorkflow' | runTheMatrix.py --interactive || exit 1 +echo 'search .*D88.*' | runTheMatrix.py --interactive || exit 1 +echo 'dumpWorkflowId 1.0' | runTheMatrix.py --interactive || exit 1 +echo 'searchInWorkflow standard .*' | runTheMatrix.py --interactive || exit 1 +echo 'wrongCommand' | runTheMatrix.py --interactive || exit 0 +