client_shell
Telnet client shell implementations for interactive terminal sessions.
- class InputFilter(seq_xlat, byte_xlat, esc_delay=0.35)[source]
Translate terminal escape sequences and single bytes to retro encoding bytes.
Combines single-byte translation (backspace, delete) with multi-byte escape sequence matching (arrow keys, function keys). Uses prefix-based buffering inspired by blessed’s
get_leading_prefixesto handle sequences split across reads.When a partial match is buffered (e.g. a bare ESC),
has_pendingbecomesTrue. The caller should start anesc_delaytimer and callflush()if no further input arrives before the timer fires.- Parameters:
Initialize input filter with sequence and byte translation tables.
- flush()[source]
Flush buffered bytes, applying single-byte translation.
Called when the
esc_delaytimer fires without new input, meaning the buffered prefix is not a real escape sequence.- Return type:
- Returns:
Translated bytes from the buffer (may be empty).
- class TelnetTerminalShell[source]
Abstract base for telnet client terminal context managers.
Defines the interface used by
_telnet_client_shell_impland_raw_event_loop. Concrete implementations areTerminal(POSIX) andTerminal(Windows).The type parameter
_ModeTis the platform-specific terminal mode descriptor (a namedtuple). Subclasses bind it to their own concrete mode type so thatset_mode()and_make_raware type-safe within each platform.- abstractmethod async make_stdout()[source]
Return a writer for local terminal output.
- Return type:
_StdoutWriter
- abstractmethod async connect_stdin()[source]
Connect stdin to an asyncio
StreamReaderand return it.- Return type:
- abstractmethod disconnect_stdin(reader)[source]
Disconnect the stdin pipe and signal EOF to reader.
- Return type:
- abstractmethod set_mode(mode)[source]
Apply terminal mode settings; a
Nonemode is a no-op.- Return type:
- async telnet_client_shell(telnet_reader, telnet_writer)[source]
Minimal telnet client shell for POSIX terminals.
This shell performs minimal tty mode handling when a terminal is attached to standard in (keyboard), notably raw mode is often set and this shell may exit only by disconnect from server, or the escape character, ^].
stdin or stdout may also be a pipe or file, behaving much like nc(1).
- Return type: