pex.proto.channel.client

Module Contents

class pex.proto.channel.client.ChannelClient(client: socket.socket)

Bases: object

Subclass of pex.proto.channel module.

This subclass of pex.proto.channel module represents Python implementation of the channel client.

stash() bytes

Return stashed data.

Return bytes:

stashed data

disconnect() None

Disconnect connected socket.

Return None:

None

send(data: bytes) None

Send data to the channel socket.

Parameters:

data (bytes) – data to send

Return None:

None

Raises:

RuntimeError – with trailing error message

read(size: int) bytes

Read data from the channel socket.

Parameters:

size (int) – size of data

Return bytes:

read data

Raises:

RuntimeError – with trailing error message

readall() bytes

Read all possible data from the channel socket.

Return bytes:

read data

Raises:

RuntimeError – with trailing error message

read_until(token: str) bytes

Read data from the channel socket until specific token.

Parameters:

token (str) – token to read data until

Return bytes:

read data

Raises:

RuntimeError – with trailing error message

send_command(command: str, output: bool = True, decode: bool = False, newline: bool = True) str | None | bytes

Send command to the channel socket.

Parameters:
  • command (str) – command to send

  • output (bool) – True if wait for output else False

  • decode (bool) – True if decode else False

  • newline (bool) – True to add newline char else False

Return Union[str, None, bytes]:

output if output is True else None

Raises:

RuntimeError – with trailing error message

send_token_command(command: str, token: str, output: bool = True, decode: bool = False, newline: bool = True) str | None | bytes

Send command and read output until specific token.

Parameters:
  • command (str) – command to send

  • token (str) – token to read data until

  • output (bool) – True if wait for output else False

  • decode (bool) – True if decode else False

  • newline (bool) – True to add newline char else False None for not printing but returning read data

Return Union[str, None, bytes]:

output if output is True and printer is None else None

interact(terminator: str = '\n') None

Interact with the channel socket.

Parameters:

terminator (str) – data to send after each command

Return None:

None

Raises:

RuntimeWarning – with trailing warning message