def main(): # Set up the root Tk context root = Tk() # Construct an empty window view = MainWindow(root) # Try to load the project. If any error occurs during # project load, show an error dialog project = None while project is None: try: project = DjangoProject() except ModelLoadError as e: dialog = TestLoadErrorDialog(root, e.trace) if dialog.status == dialog.CANCEL: sys.exit(1) # Set the project for the main window. # This populates the tree, and sets listeners for # future tree modifications. view.project = project # Run the main loop try: view.mainloop() except KeyboardInterrupt: view.on_quit()
def main(Model): """Run the main loop of the app. Take the project Model as the argument. This model will be instantiated as part of the main loop. """ parser = ArgumentParser() parser.add_argument("--version", help="Display version number and exit", action="store_true") Model.add_arguments(parser) options = parser.parse_args() # Check the shortcut options if options.version: import cricket print cricket.VERSION return # Set up the root Tk context root = Tk() # Construct an empty window view = MainWindow(root) # Try to load the project. If any error occurs during # project load, show an error dialog project = None while project is None: try: project = Model(options) except ModelLoadError as e: dialog = TestLoadErrorDialog(root, e.trace) if dialog.status == dialog.CANCEL: sys.exit(1) if project.errors: dialog = IgnorableTestLoadErrorDialog(root, '\n'.join(project.errors)) if dialog.status == dialog.CANCEL: sys.exit(1) # Set the project for the main window. # This populates the tree, and sets listeners for # future tree modifications. view.project = project # Run the main loop try: view.mainloop() except KeyboardInterrupt: view.on_quit()
def main(Model): """Run the main loop of the app. Take the project Model as the argument. This model will be instantiated as part of the main loop. """ # Set up the root Tk context root = Tk() # Construct an empty window view = MainWindow(root) # Try to load the project. If any error occurs during # project load, show an error dialog project = None while project is None: try: project = Model() except ModelLoadError as e: dialog = TestLoadErrorDialog(root, e.trace) if dialog.status == dialog.CANCEL: sys.exit(1) if project.errors: dialog = IgnorableTestLoadErrorDialog(root, '\n'.join(project.errors)) if dialog.status == dialog.CANCEL: sys.exit(1) # Set the project for the main window. # This populates the tree, and sets listeners for # future tree modifications. view.project = project # Run the main loop try: view.mainloop() except KeyboardInterrupt: view.on_quit()
def main(Model): """Run the main loop of the app. Take the project Model as the argument. This model will be instantiated as part of the main loop. """ parser = ArgumentParser() parser.add_argument("--version", help="Display version number and exit", action="store_true") Model.add_arguments(parser) options = parser.parse_args() # Check the shortcut options if options.version: import cricket print(cricket.VERSION) return # Set up the root Tk context root = Tk() # Construct an empty window view = MainWindow(root) # Try to load the project. If any error occurs during # project load, show an error dialog project = None while project is None: try: # Create the project objects project = Model(options) runner = subprocess.Popen( project.discover_commandline(), stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, ) test_list = [] for line in runner.stdout: test_list.append(line.strip().decode('utf-8')) errors = [] for line in runner.stderr: errors.append(line.strip()) if errors and not test_list: raise ModelLoadError('\n'.join( [e.decode('utf-8') for e in errors])) project.refresh(test_list, errors) except ModelLoadError as e: # Load failed; destroy the project and show an error dialog. # If the user selects cancel, quit. project = None dialog = TestLoadErrorDialog(root, e.trace) if dialog.status == dialog.CANCEL: sys.exit(1) if project.errors: dialog = IgnorableTestLoadErrorDialog(root, '\n'.join(project.errors)) if dialog.status == dialog.CANCEL: sys.exit(1) # Set the project for the main window. # This populates the tree, and sets listeners for # future tree modifications. view.project = project # Run the main loop try: view.mainloop() except KeyboardInterrupt: view.on_quit()
def main(Model): """Run the main loop of the app. Take the project Model as the argument. This model will be instantiated as part of the main loop. """ parser = ArgumentParser() parser.add_argument("--version", help="Display version number and exit", action="store_true") Model.add_arguments(parser) options = parser.parse_args() # Check the shortcut options if options.version: import cricket print(cricket.VERSION) return # Set up the root Tk context root = Tk() # Construct an empty window view = MainWindow(root) # Try to load the project. If any error occurs during # project load, show an error dialog project = None while project is None: try: # Create the project objects project = Model(options) runner = subprocess.Popen( project.discover_commandline(), stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, ) test_list = [] for line in runner.stdout: test_list.append(line.strip().decode('utf-8')) errors = [] for line in runner.stderr: errors.append(line.strip()) if errors and not test_list: raise ModelLoadError('\n'.join(errors)) project.refresh(test_list, errors) except ModelLoadError as e: # Load failed; destroy the project and show an error dialog. # If the user selects cancel, quit. project = None dialog = TestLoadErrorDialog(root, e.trace) if dialog.status == dialog.CANCEL: sys.exit(1) if project.errors: dialog = IgnorableTestLoadErrorDialog(root, '\n'.join(project.errors)) if dialog.status == dialog.CANCEL: sys.exit(1) # Set the project for the main window. # This populates the tree, and sets listeners for # future tree modifications. view.project = project # Run the main loop try: view.mainloop() except KeyboardInterrupt: view.on_quit()
def main(Model): """Run the main loop of the app. Take the project Model as the argument. This model will be instantiated as part of the main loop. """ parser = ArgumentParser() parser.add_argument("--version", action="store_true", help="Display version number and exit") parser.add_argument("--debug", "-d", action="store_true", help="Turn on debug prints (to console). Also pass python '-u'") parser.add_argument("--save", help="Set path to save test output. <TESTNAME> and <DATETIME> are replaced") parser.add_argument("testdir", action="store", default="", nargs='?', help="Test root directory. Default is current directory") Model.add_arguments(parser) options = parser.parse_args() # Check the shortcut options if options.version: import cricket print(cricket.__version__) sys.exit(2) if options.debug: set_debug(True) if options.testdir: os.chdir(options.testdir) # Set up the root Tk context debug("Starting GUI init") root = Tk() # Construct an empty window view = MainWindow(root, options=options) # Try to load the test_suite. If any error occurs during # test_suite load, show an error dialog test_suite = None while test_suite is None: try: debug("Discovering initial test_suite") test_suite = Model(options) test_suite.refresh() except ModelLoadError as e: # Load failed; destroy the test_suite and show an error dialog. # If the user selects cancel, quit. debug("Test_Suite initial failed. Find error dialog and click on quit") test_suite = None dialog = TestLoadErrorDialog(root, e.trace) if dialog.status == dialog.CANCEL: sys.exit(1) if test_suite.errors: dialog = IgnorableTestLoadErrorDialog(root, '\n'.join(test_suite.errors)) if dialog.status == dialog.CANCEL: sys.exit(1) # Set the test_suite for the main window. # This populates the tree, and sets listeners for # future tree modifications. view.test_suite = test_suite if is_debug(): count, labels = test_suite.find_tests(allow_all=True) debug("Found %d tests:", count) debug("%s", '\n'.join(labels)) # Run the main loop try: debug("Starting GUI mainloop") view.mainloop() except KeyboardInterrupt: view.on_quit()