opengsq package

Subpackages

Submodules

opengsq.binary_reader module

class opengsq.binary_reader.BinaryReader(data: bytes)

Bases: object

remaining_bytes() int
is_end() bool
prepend_bytes(data)
read() bytes
read_byte() int
read_bytes(count: int) bytes
read_short(unsigned=True) int
read_long(unsigned=False) int
read_long_long() int
read_float() float
read_string(delimiters=[b'\x00'], encoding='utf-8', errors='ignore') str
read_pascal_string(encoding='utf-8', errors='ignore')

opengsq.cli module

class opengsq.cli.CLI

Bases: object

register(parser: ArgumentParser)
async run(args: Sequence[str]) str
opengsq.cli.main()
async opengsq.cli.main_async()

opengsq.protocol_base module

class opengsq.protocol_base.ProtocolBase(host: str, port: int, timeout: float = 5.0)

Bases: ABC

abstract property full_name: str

opengsq.protocol_socket module

class opengsq.protocol_socket.SocketKind(value)

Bases: Enum

SOCK_STREAM = 1
SOCK_DGRAM = 2
class opengsq.protocol_socket.Socket(kind: SocketKind)

Bases: object

async static gethostbyname(hostname: str)
class Protocol(timeout: float)

Bases: Protocol

async recv()
connection_made(transport)

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

connection_lost(exc)

Called when the connection is lost or closed.

The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).

data_received(data)

Called when some data is received.

The argument is a bytes object.

eof_received()

Called when the other end calls write_eof() or equivalent.

If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol.

datagram_received(data, addr)
error_received(exc)
bind_port(port: int)
settimeout(value: float)
async connect(remote_addr)
close()
send(data: bytes)
async recv(size: int = None) bytes
class opengsq.protocol_socket.UdpClient

Bases: Socket

async static communicate(protocol: ProtocolBase, data: bytes, source_port: int = None)
class opengsq.protocol_socket.TcpClient

Bases: Socket

async static communicate(protocol: ProtocolBase, data: bytes)

opengsq.version module

Module contents

OpenGSQ Python Library

Python library for querying game servers

copyright:
  1. 2021 BattlefieldDuck

license:

MIT, see LICENSE for more details.