Esempio n. 1
0
def _send_specified_file(_ui: UserInput):
    """_send_specified_file()

    ui is a UserInput

    opens the controller, the commandreader, and
    sends each line to the controller.

    """

    _ui.open()
    _c: Controller = Controller(_ui)
    _cr = CommandReader(_ui)
    _cr.open()
    _c.open()
    try:
        while 1:
            line: str = _cr.get()
            if line == "":
                break  # exit when file read
            _c.sendcmd(line, echoit=_DEBUGGING)
    finally:
        _c.close()
        _cr.close()
        _ui.close()
Esempio n. 2
0
def send_users_cmds(_ui: UserInput) -> bool:
    """sendUsersCmds()

    Opens the ui and controller,
    runs the command loop
    closes the controller and the ui.

    """

    _ui.open()
    _c = Controller(_ui)
    _c.open()
    try:
        _cmdloop(_c)
    finally:
        _c.close()
        _ui.close()
    return True
Esempio n. 3
0
def do_utility_cmds(_ui: UserInput) -> bool:
    """doUtilityCmds(ui)

    Asks for the log file name, opens the ui, and the controller.
    Calls the util processor loop,
    Closes the controller and the ui on exit
    """

    _ui.inputfn = input("input log file name.txt>")
    _ui.open()
    _c: Controller = Controller(_ui)
    _c.open()
    try:
        _utils: Utils = Utils(_ui, _c)
        _utils.process_loop()
    finally:
        _c.close()
        _ui.close()
    return True
Esempio n. 4
0
        maxBytes=10000,
        backupCount=5,
    )
    LF_HANDLER.setLevel(logging.DEBUG)
    LC_HANDLER = logging.StreamHandler()
    LC_HANDLER.setLevel(logging.DEBUG)  # (logging.ERROR)
    LF_FORMATTER = logging.Formatter(
        '%(asctime)s - %(name)s - %(funcName)s - %(levelname)s - %(message)s')
    LC_FORMATTER = logging.Formatter('%(name)s: %(levelname)s - %(message)s')
    LC_HANDLER.setFormatter(LC_FORMATTER)
    LF_HANDLER.setFormatter(LF_FORMATTER)
    THE_LOGGER = logging.getLogger()
    THE_LOGGER.setLevel(logging.DEBUG)
    THE_LOGGER.addHandler(LF_HANDLER)
    THE_LOGGER.addHandler(LC_HANDLER)
    THE_LOGGER.info('userinput executed as main')
    # LOGGER.setLevel(logging.DEBUG)
    MS = MySerial()
    MS.open()
    from userinput import UserInput
    _UI = UserInput()
    try:
        _UI.request()
        _UI.open()
        print("Requested Port can be opened")
        _UI.close()

    except(Exception, KeyboardInterrupt) as exc:
        _UI.close()
        sys.exit(str(exc))