def main(argv):
    """qashell [-dD]
    Run the QA shell.
    """
    from pycopia import getopt
    debug = 0
    try:
        optlist, longopts, args = getopt.getopt(argv[1:], "?hdD")
    except getopt.GetoptError:
            print(main.__doc__)
            return
    for opt, val in optlist:
        if opt in ("-?", "-h"):
            print(main.__doc__)
            return
        elif opt == "-d":
            debug += 1
        elif opt == "-D":
            from pycopia import autodebug

    if debug:
        from pycopia import logwindow
        widgets.DEBUG = logwindow.DebugLogWindow(do_stderr=True)

    app = TestRunnerShell()
    try:
        app.run()
    except:
        if debug:
            ex, val, tb = sys.exc_info()
            from pycopia import debugger
            if debug > 1:
                from pycopia import IOurxvt
                io = IOurxvt.UrxvtIO()
            else:
                io = None
            debugger.post_mortem(tb, ex, val, io)
            widgets.DEBUG.close()
            if debug > 1:
                io.close()
        else:
            raise
dataset/ETHPy150Open kdart/pycopia/QA/pycopia/QA/tui/main.py/main/original