コード例 #1
0
ファイル: cli.py プロジェクト: githubato/sen-arm
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine"
    )
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    # if args.debug:
    set_logging(level=logging.DEBUG, path=get_log_file_path())
    # else:
    #     set_logging(level=logging.INFO, path=setup_dirs())

    logger.info("application started")

    try:
        ui = UI()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    except Exception as ex:  # pylint: disable=broad-except
        if args.debug:
            raise
        else:
            logger.error("Exception caught: %r", ex)
            return 1
    return 0
コード例 #2
0
ファイル: cli.py プロジェクト: pabardina/sen
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine")
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    # if args.debug:
    set_logging(level=logging.DEBUG, path=get_log_file_path())
    # else:
    #     set_logging(level=logging.INFO, path=setup_dirs())

    logger.info("application started")

    try:
        ui = UI()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    except Exception as ex:  # pylint: disable=broad-except
        if args.debug:
            raise
        else:
            logger.error("Exception caught: %r", ex)
            return 1
    return 0
コード例 #3
0
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine")
    parser.add_argument(
        "--yolo",
        "--skip-prompt-for-irreversible-action",
        action="store_true",
        default=False,
        help="Don't prompt when performing irreversible actions, a.k.a. YOLO!")
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug",
                                 action="store_true",
                                 default=None,
                                 help="Set logging level to debug")

    args = parser.parse_args()

    # !IMPORTANT! make sure that sen does NOT log via `logging.info` b/c it sets up root logger
    # and adds StreamHandler which causes to display logs on stdout which is definitely what we
    # don't want in a terminal app (thanks to Slavek Kabrda for explanation)
    if args.debug:
        set_logging(level=logging.DEBUG, path=get_log_file_path())
        logger.debug("sen loaded from %s", sen.__file__)
    else:
        set_logging(level=logging.INFO, path=get_log_file_path())

    logger.info("application started")

    try:
        app = Application(yolo=args.yolo)
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        app.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    except Exception as ex:  # pylint: disable=broad-except
        log_last_traceback()
        if args.debug:
            raise
        else:
            # TODO: improve this message to be more thorough
            print(
                "There was an error during program execution, see logs for more info."
            )
            return 1
    return 0
コード例 #4
0
ファイル: cli.py プロジェクト: andrewrothstein/sen
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine")
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    if args.debug:
        set_logging(level=logging.DEBUG, path=get_log_file_path())
    else:
        set_logging(level=logging.INFO, path=get_log_file_path())

    logger.info("application started")

    try:
        ui = Application()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    # except AssertionError as ex:
    # if ex.args[0] == "rows, render mismatch":
    #     logger.error("race condition happened")
    #     # restart the ui
    #     # # continue
    #    return 2
    except Exception as ex:  # pylint: disable=broad-except
        log_vars_from_tback(
            process_frames=3 if args.debug else 0)  # show complete stack trace
        if args.debug:
            raise
        else:
            # TODO: improve this message to be more thorough
            print(
                "There was an error during program execution, see logs for more info."
            )
            return 1
    return 0
コード例 #5
0
ファイル: cli.py プロジェクト: andrewrothstein/sen
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine"
    )
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    if args.debug:
        set_logging(level=logging.DEBUG, path=get_log_file_path())
    else:
        set_logging(level=logging.INFO, path=get_log_file_path())

    logger.info("application started")

    try:
        ui = Application()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    # except AssertionError as ex:
        # if ex.args[0] == "rows, render mismatch":
        #     logger.error("race condition happened")
        #     # restart the ui
        #     # # continue
    #    return 2
    except Exception as ex:  # pylint: disable=broad-except
        log_vars_from_tback(process_frames=3 if args.debug else 0)  # show complete stack trace
        if args.debug:
            raise
        else:
            # TODO: improve this message to be more thorough
            print("There was an error during program execution, see logs for more info.")
            return 1
    return 0
コード例 #6
0
ファイル: cli.py プロジェクト: TomasTomecek/sen
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine"
    )
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    # !IMPORTANT! make sure that sen does NOT log via `logging.info` b/c it sets up root logger
    # and adds StreamHandler which causes to display logs on stdout which is definitely what we
    # don't want in a terminal app (thanks to Slavek Kabrda for explanation)
    if args.debug:
        set_logging(level=logging.DEBUG, path=get_log_file_path())
    else:
        set_logging(level=logging.INFO, path=get_log_file_path())

    logger.info("application started")

    try:
        ui = Application()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    except Exception as ex:  # pylint: disable=broad-except
        log_last_traceback()
        if args.debug:
            raise
        else:
            # TODO: improve this message to be more thorough
            print("There was an error during program execution, see logs for more info.")
            return 1
    return 0
コード例 #7
0
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine")
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    if args.debug:
        set_logging(level=logging.DEBUG, path=get_log_file_path())
    else:
        set_logging(level=logging.INFO, path=get_log_file_path())

    logger.info("application started")

    try:
        ui = Application()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    except Exception as ex:  # pylint: disable=broad-except
        log_last_traceback()
        if args.debug:
            raise
        else:
            # TODO: improve this message to be more thorough
            print(
                "There was an error during program execution, see logs for more info."
            )
            return 1
    return 0
コード例 #8
0
ファイル: cli.py プロジェクト: pwielgolaski/sen
def main():
    parser = argparse.ArgumentParser(
        description="Terminal User Interface for Docker Engine"
    )
    exclusive_group = parser.add_mutually_exclusive_group()
    exclusive_group.add_argument("--debug", action="store_true", default=None)

    args = parser.parse_args()

    # if args.debug:
    set_logging(level=logging.DEBUG, path=get_log_file_path())
    # else:
    #     set_logging(level=logging.INFO, path=setup_dirs())

    logger.info("application started")

    try:
        ui = UI()
    except TerminateApplication as ex:
        print("Error: {0}".format(str(ex)), file=sys.stderr)
        return 1

    try:
        ui.run()
    except KeyboardInterrupt:
        print("Quitting on user request.")
        return 1
    except Exception as ex:  # pylint: disable=broad-except
        if args.debug:
            raise
        else:
            # TODO: improve this message to be more thorough
            # FIXME: reset terminal and remove all the curses crap
            print("There was an error during program execution, see logs for more info.")
            logger.debug(traceback.format_exc())
            return 1
    return 0