rcon package

Subpackages

Submodules

rcon.client module

Common base client.

class rcon.client.BaseClient(host: str, port: int, *, timeout: float | None = None, passwd: str | None = None)

Bases: object

A common RCON client.

close() None

Close the socket connection.

connect(login: bool = False) None

Connect the socket and attempt a login if wanted and a password is set.

login(passwd: str) bool

Perform a login.

run(command: str, *args: str) str

Run a command.

property timeout: float

Return the socket timeout.

rcon.config module

RCON server configuration.

class rcon.config.Config(host: str, port: int, passwd: str | None = None)

Bases: NamedTuple

Represents server configuration.

classmethod from_config_section(section: SectionProxy) Config

Create a credentials tuple from the respective config section.

classmethod from_string(string: str) Config

Read the credentials from the given string.

host: str

Alias for field number 0

passwd: str | None

Alias for field number 2

port: int

Alias for field number 1

rcon.config.from_args(args: Namespace) Config

Get the credentials for a server from the respective arguments.

rcon.console module

An interactive console.

rcon.console.rconcmd(client_cls: Type[BaseClient], host: str, port: int, passwd: str, *, timeout: float | None = None, prompt: str = 'RCON {host}:{port}> ')

Initialize the console.

rcon.errorhandler module

Common errors handler.

class rcon.errorhandler.ErrorHandler(logger: Logger)

Bases: object

Handles common errors and exits.

exit_code
logger

rcon.exceptions module

Common exceptions.

exception rcon.exceptions.ConfigReadError

Bases: Exception

Indicates an error while reading the configuration.

exception rcon.exceptions.EmptyResponse

Bases: Exception

Indicates an empty response from the server.

exception rcon.exceptions.SessionTimeout

Bases: Exception

Indicates that the session timed out.

exception rcon.exceptions.UserAbort

Bases: Exception

Indicates that a required action has been aborted by the user.

exception rcon.exceptions.WrongPassword

Bases: Exception

Indicates a wrong password.

rcon.gui module

GTK based GUI.

rcon.gui.main() None

Start the GUI.

rcon.rconclt module

RCON client CLI.

rcon.rconclt.main() int

Run the main script with exceptions handled.

rcon.rconshell module

An interactive RCON shell.

rcon.rconshell.get_args() Namespace

Parse and returns the CLI arguments.

rcon.rconshell.main() int

Run the main script with exceptions handled.

rcon.readline module

Wrapper for readline support.

class rcon.readline.CommandHistory(logger: Logger, file: Path = PosixPath('/sbuild-nonexistent/.rconshell_history'))

Bases: object

Context manager for the command line history.

Module contents

RCON client library.

class rcon.Client(*args, **kwargs)

Bases: Client

Wrapper for the rcon.source.Client for backwards compatibility.

exception rcon.EmptyResponse

Bases: Exception

Indicates an empty response from the server.

exception rcon.SessionTimeout

Bases: Exception

Indicates that the session timed out.

exception rcon.WrongPassword

Bases: Exception

Indicates a wrong password.

rcon.rcon(*args, **kwargs) Coroutine[Any, Any, str]

Wrapper for rcon.source.rcon() for backwards compatibility.