Example #1
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
Example #2
0
File: ui.py Project: f-cap/sen
def run_command_callback(ui, edit_widget, text_input):
    logger.debug("%r %r", edit_widget, text_input)
    if text_input.endswith("\n"):
        inp = text_input.strip()
        try:
            ui.run_command(inp)
        except NoSuchCommand as ex:
            logger.info("non-existent command initiated: %r", inp)
            ui.notify_message(str(ex), level="error")
        except Exception as ex:
            logger.info("command %r failed: %r", inp, ex)
            ui.notify_message("Error while running command '{}': {}".format(
                inp, ex
            ), level="error")
            log_last_traceback()
        ui.prompt_bar = None
        ui.set_focus("body")
        ui.reload_footer()
Example #3
0
def run_command_callback(ui, docker_object, edit_widget, text_input):
    logger.debug("%r %r", edit_widget, text_input)
    if "\n" in text_input:
        inp = text_input.strip()
        inp = inp.replace("\n", "")
        # first restore statusbar and then run the command
        ui.prompt_bar = None
        ui.set_focus("body")
        try:
            ui.run_command(inp, docker_object=docker_object)
        except NoSuchCommand as ex:
            logger.info("non-existent command initiated: %r", inp)
            ui.notify_message(str(ex), level="error")
        except Exception as ex:
            logger.info("command %r failed: %r", inp, ex)
            ui.notify_message("Error while running command '{}': {}".format(
                inp, ex),
                              level="error")
            log_last_traceback()
        ui.reload_footer()
Example #4
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()

    # !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
Example #5
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
Example #6
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