runtimepy.net.tcp.telnet package

Contents

runtimepy.net.tcp.telnet package#

Submodules#

runtimepy.net.tcp.telnet.codes module#

Code enumerations relevant to the telnet (RFC 854) protocol.

class runtimepy.net.tcp.telnet.codes.TelnetCode(*values)[source]#

Bases: IntEnum

An enumeration of byte values important to the telnet protocol.

AO = 245#
AYT = 246#
BREAK = 243#
DATA_MARK = 242#
DO = 253#
DONT = 254#
EC = 247#
EL = 248#
GA = 249#
IAC = 255#
IP = 244#
NOP = 241#
SB = 250#
SE = 240#
WILL = 251#
WONT = 252#
static is_option_code(val: int) bool[source]#

Determine if the integer value is an option code.

class runtimepy.net.tcp.telnet.codes.TelnetNvt(*values)[source]#

Bases: IntEnum

Telnet data relevant to the NVT printer and keyboard.

BEL = 7#
BS = 8#
CR = 13#
FF = 12#
HT = 9#
LF = 10#
NUL = 0#
VT = 11#
static is_nvt(val: int) bool[source]#

Determine if a byte value is an NVT printer or keyboard code.

to_stream(stream: BinaryIO) bool[source]#

Add text to the provided stream based on this NVT instance. Return whether or not any data was written to the stream.

runtimepy.net.tcp.telnet.np_05b module#

A module implementing a Telnet interface for the NP-05B.

class runtimepy.net.tcp.telnet.np_05b.Np05bConnection(transport: Transport, protocol: QueueProtocol, **kwargs)[source]#

Bases: BasicTelnet, AsyncCommandProcessingMixin

A class implementing a communication interface with the NP-05B networked PDU.

async async_init() bool[source]#

Ensure that initial statuses get set.

chan_to_idx: dict[str, int]#
default_auto_restart = True#
async handle_command(args: Namespace, channel: BitField | Channel[Int8Primitive] | Channel[Int16Primitive] | Channel[Int32Primitive] | Channel[Int64Primitive] | Channel[Uint8Primitive] | Channel[Uint16Primitive] | Channel[Uint32Primitive] | Channel[Uint64Primitive] | Channel[FloatPrimitive] | Channel[DoublePrimitive] | Channel[BooleanPrimitive] | None) None[source]#

Handle a command.

init() None[source]#

Initialize this instance.

lock: Lock#
async np05b_command(message: Np05bStrings, *parts: str) None[source]#

Send a command then read outlet states.

num_ports = 5#
prev_cmd: str#
process_response(command: Np05bStrings, command_data: str, response: str) None[source]#

Process a command response from the NP-05B.

async process_text(data: str) bool[source]#

Process a text frame.

prompt = '>'#
async request_outlet_status() None[source]#

Request that the endpoint sends information about outlet status.

async set_outlet_state(idx: int, state: bool) bool[source]#

Set the state of an outlet on the PDU. Returns whether or not the state for the specified outlet index got set.

class runtimepy.net.tcp.telnet.np_05b.Np05bStrings(*values)[source]#

Bases: Enum

Command strings for the NP-05B.

ALL_OUTLETS = '$A7'#
FAIL = '$AF'#
OK = '$A0'#
OUTLET_STATUS = '$A5'#
SET_OUTLET = '$A3'#
static is_command(data: str) bool[source]#

Determine if some string data is a command string.

Module contents#

A module implementing a basic telnet (RFC 854) connection interface.

class runtimepy.net.tcp.telnet.BasicTelnet(transport: Transport, protocol: QueueProtocol, **kwargs)[source]#

Bases: Telnet

A simple telnet implementation.

async handle_nvt(action: TelnetNvt) None[source]#

Handle a signal for the network virtual-terminal.

async process_command(code: TelnetCode) None[source]#

Process a telnet command.

async process_option(code: TelnetCode, option: int, _: BinaryIO) None[source]#

Process a telnet option.

async process_text(data: str) bool[source]#

Process a text frame.

class runtimepy.net.tcp.telnet.Telnet(transport: Transport, protocol: QueueProtocol, **kwargs)[source]#

Bases: TcpConnection

A class implementing a basic telnet interface.

abstractmethod async handle_nvt(action: TelnetNvt) None[source]#

Handle a signal for the network virtual-terminal.

log_alias = 'TELNET'#
async process_binary(data: bytes) bool[source]#

Process a binary frame.

abstractmethod async process_command(code: TelnetCode) None[source]#

Process a telnet command.

abstractmethod async process_option(code: TelnetCode, option: int, stream: BinaryIO) None[source]#

Process a telnet option.

async process_telnet_message(data: bytes) bool[source]#

By default, treat all incoming data bytes as text.

send_command(code: TelnetCode) None[source]#

Send a telnet command.

send_option(option: TelnetCode, code: int) None[source]#

Send a telnet option sequence. if the ‘SB’ is the desired code, the additional data can be sent using the ‘send_binary’ method directly.

class runtimepy.net.tcp.telnet.TelnetCode(*values)[source]#

Bases: IntEnum

An enumeration of byte values important to the telnet protocol.

AO = 245#
AYT = 246#
BREAK = 243#
DATA_MARK = 242#
DO = 253#
DONT = 254#
EC = 247#
EL = 248#
GA = 249#
IAC = 255#
IP = 244#
NOP = 241#
SB = 250#
SE = 240#
WILL = 251#
WONT = 252#
static is_option_code(val: int) bool[source]#

Determine if the integer value is an option code.

class runtimepy.net.tcp.telnet.TelnetNvt(*values)[source]#

Bases: IntEnum

Telnet data relevant to the NVT printer and keyboard.

BEL = 7#
BS = 8#
CR = 13#
FF = 12#
HT = 9#
LF = 10#
NUL = 0#
VT = 11#
static is_nvt(val: int) bool[source]#

Determine if a byte value is an NVT printer or keyboard code.

to_stream(stream: BinaryIO) bool[source]#

Add text to the provided stream based on this NVT instance. Return whether or not any data was written to the stream.