tamcolors.utils package

Submodules

tamcolors.utils.compress module

tamcolors.utils.compress.compress(data)

info: will compress data :param data: bytes :return: bytes

tamcolors.utils.compress.decompress(data)

info: will defcompress data :param data: bytes :return: bytes

tamcolors.utils.encryption module

class tamcolors.utils.encryption.Encryption(rsa_key_size=4096, aes_key_size=256, nonce_key_size=64, authenticator=b'', max_random=20)

Bases: object

static check_sandy_check_key(sandy_key, data)

info: Checks if the sandy key is equal to the data key. :param sandy_key: bytes: sha hash key :param data: bytes: :return: bool

decrypt(data)

info: Decrypt message. The data will also be checked for corruption. :param data: bytes :return: bytes: Unencrypted data.

encrypt(data)

info: Encrypts data. :param data: bytes :return: bytes: Encrypted data.

encrypt_with_public_key(key, data)

info: Encrypts data with public key. :param key: bytes or ras key object :param data: bytes :return: bytes: encrypted data

get_raw_private_key()

info: Gets the raw private key. :return: bytes: PEM encoding

get_raw_public_key()

info: gets the raw public key. :return: bytes: PEM encoding

static make_sandy_check_key(data)

info: Hashes data. :param data: bytes :return: bytes: Hash key.

exception tamcolors.utils.encryption.EncryptionError

Bases: Exception

tamcolors.utils.identifier module

tamcolors.utils.identifier.generate_identifier_bytes(identifier_file='/home/docs/checkouts/readthedocs.org/user_builds/tamcolors/checkouts/latest/tamcolors/utils/identifier.id', identifier_size=500)
tamcolors.utils.identifier.get_identifier_bytes(identifier_file='/home/docs/checkouts/readthedocs.org/user_builds/tamcolors/checkouts/latest/tamcolors/utils/identifier.id')

tamcolors.utils.immutable_cache module

class tamcolors.utils.immutable_cache.ImmutableCache

Bases: object

tamcolors.utils.log module

class tamcolors.utils.log.Log(size=5000)

Bases: object

first_msg_id()
last_msg_id()
log(msg)
read(log_id)
tamcolors.utils.log.critical(msg)

info: log at critical level :param msg: str :return:

tamcolors.utils.log.debug(msg)

info: log at debug level :param msg: str :return:

tamcolors.utils.log.disable_logging()

info: will disable logging :return:

tamcolors.utils.log.enable_logging(level=10)

info: will enable logging at a level :param level: log level :return:

tamcolors.utils.log.error(msg)

info: log at debug level :param msg: str :return:

tamcolors.utils.log.format_message(func)
tamcolors.utils.log.info(msg)

info: log at info level :param msg: str :return:

tamcolors.utils.log.warning(msg)

info: log at warning level :param msg: str :return:

tamcolors.utils.object_packer module

class tamcolors.utils.object_packer.FastHandObjectPacker

Bases: object

classmethod from_bytes(object_byte_array)

info: from bytes to object :param object_byte_array: bytearray :return: object

classmethod start_from_bytes(object_bytes)

info: from bytes to object :param object_bytes: bytearray, bytes, list, tuple :return: object

to_bytes()

info: object to bytes :return: bytes

class tamcolors.utils.object_packer.ObjectPackerJson(fast_hand_object_packer_objects=None)

Bases: object

dumps(data)

info: object to bytes :param data: object :return: bytes

loads(data)

info: bytes to object :param data: bytearray, bytes, list, tuple :return: object

exception tamcolors.utils.object_packer.ObjectPackerJsonError

Bases: Exception

tamcolors.utils.object_packer.load_data(object_byte_array)

info: Loads bytes :param object_byte_array: bytearray :return: bytes

tamcolors.utils.object_packer.load_int(object_byte_array)

info: Loads an unsigned int :param object_byte_array: bytearray :return: int

tamcolors.utils.object_packer.save_data

info: Saves bytes :param data: bytes :return: bytes

tamcolors.utils.object_packer.save_int

info: Saves an unsigned int :param number: int :return: bytes

tamcolors.utils.tcp module

class tamcolors.utils.tcp.TCPBase(connection, address, port, connection_password, encryption=None, object_packer=None, our_information=None)

Bases: object

close()

info: will close the connection :return: None

get_address()

info: will get the address :return: str

get_data()

info: will compress and encrypt data if encryption is enabled :return: bytes

is_open()

info: will check if connection is open :return: bool

send_data(data)

info: will compress and decrypt if encryption is enabled :param data: bytes :return: None

class tamcolors.utils.tcp.TCPConnection(host='127.0.0.1', port=4444, ipv6=False, connection_password='', user_name=None, user_id=None, encryption=None, object_packer=None, our_information=None)

Bases: tamcolors.utils.tcp.TCPBase

get_other_data()

info: will get other data :return: object

exception tamcolors.utils.tcp.TCPError

Bases: Exception

class tamcolors.utils.tcp.TCPHost(*args, **kwargs)

Bases: tamcolors.utils.tcp.TCPBase

get_other_data()

info: will get other data :return: object

get_user_id()

info: get connection id :return: bytes

get_user_name()

info: get connection name :return: str

class tamcolors.utils.tcp.TCPObjectConnector(tcp_connection, object_packer=None, no_return=None, optimizer=None, none_generator=None)

Bases: object

close()

info: will close the object :return:

get_connection()

info: will get connection :return: TCPBase

is_open()

info: will check if object is still open :return: bool

class tamcolors.utils.tcp.TCPObjectWrapper(tcp_connection, obj, object_packer=None)

Bases: object

close()

info: will close the object :return:

get_connection()

info: will get connection :return: TCPBase

is_open()

info: will check if object is still open :return: bool

class tamcolors.utils.tcp.TCPReceiver(host='127.0.0.1', port=4444, ipv6=False, listen_count=10, connection_password='', address_white_list=None, address_black_list=None, encryption=None, object_packer=None, our_information=None)

Bases: object

close()

info: will close tcp receiver connection :return: None

get_host_connection(wait=True)

info: will get a new host connection :param wait: bool: if true will wait for a connection :return: None or TCPHost

tamcolors.utils.timer module

class tamcolors.utils.timer.TickRateTracker(frame=1)

Bases: object

tick()

info: will add a tick :return:

tick_rate()

info: will get tick rate :return: int

class tamcolors.utils.timer.Timer(time_corruption=0)

Bases: object

lap()

Gets time difference from last lap. :return: float

offset_sleep(sleep_time)

Will sleep the thread for a length of time based of the lap time. :param sleep_time: float :return: float

tamcolors.utils.transport_optimizer module

class tamcolors.utils.transport_optimizer.LastReceivedCache

Bases: object

class tamcolors.utils.transport_optimizer.LastSentCache

Bases: object

Module contents