3 # Interactive shell for using QA test suite
8 from optparse import OptionParser
9 from traceback import print_exc
12 from qa.QAAPI import QAAPI
14 sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
16 parser = OptionParser(add_help_option = False)
17 parser.add_option("-f", "--config", help = "configuration file")
18 parser.add_option("-l", "--log", help="enable logging")
19 parser.add_option("--help", action = "help", help = "show this help message and exit")
20 (options, args) = parser.parse_args()
22 # XX Load callable tests
28 except Exception, err:
33 # If called by a script
34 if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
35 # Pop us off the argument stack
42 # Readline and tab completion support
47 print 'Type "help" for more information.'
48 # Load command history
49 history_path = os.path.join(os.environ["HOME"], ".qa_history")
51 file(history_path, 'a').close()
52 readline.read_history_file(history_path)
53 atexit.register(readline.write_history_file, history_path)
57 # Enable tab completion
58 readline.parse_and_bind("tab: complete")
70 line = raw_input(prompt + sep)
72 except KeyboardInterrupt:
77 # Build up multi-line command
80 # Blank line or first line does not end in :
81 if line == "" or (command == line and line[-1] != ':'):
90 elif command in ["q", "quit", "exit"]:
95 # Try evaluating as an expression and printing the result
96 result = eval(command)
97 if result is not None:
100 # Fall back to executing as a statement
102 except Exception, err: