movai_core_shared.core package

Subpackages

Submodules

movai_core_shared.core.base_command module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Erez Zomer (erez@mov.ai) - 2022

class movai_core_shared.core.base_command.BaseCommand(**kwargs)

Bases: ABC

Base Class for the various tools commands.

abstract classmethod define_arguments(subparsers) None

An abstract function for implementing command arguments.

Parameters:

subparsers (_type_) – _description_

abstract execute(**kwargs) None

Executes the relevant command.

property name: str

return the name of the command

safe_execute(**kwargs) None

Executes the command in try except block.

movai_core_shared.core.message_client module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Usage:

Sends messages to the robot Message-Server.

Developers: - Ofer Katz (ofer@mov.ai) - 2022 - Erez Zomer (erez@mov.ai) - 2022

class movai_core_shared.core.message_client.AsyncMessageClient(server_addr: str, robot_id: str = '')

Bases: MessageClient

async forward_request(request_msg: dict) dict

Send the request asynchronously to different message-server (This function does not adds the meta-data info as send_request does).

Parameters:

request_msg (dict) – The request to forward.

async send_msg(data: dict, **kwargs) None

sends a simple message as raw data asynchrously, won’t wait for response

Parameters:

data (dict) – The data to send to server.

async send_request(msg_type: str, data: dict, creation_time: datetime | None = None, response_required: bool = False) dict

Wrap the data into a message request and sent it asynchonously to the robot message server (can not wait for a response).

Parameters:
  • msg_type (str) – the type of message.

  • data (dict) – The message data to be sent to the robot message server.

  • creation_time (str) – The time where the request is created.

  • response_required (bool) – whether to wait for response, Default False.

class movai_core_shared.core.message_client.MessageClient(server_addr: str, robot_id: str = '')

Bases: object

This class is the client for message-server. It wraps the data into the message structure and send it to the message-server using ZMQClient.

forward_request(request_msg: dict) dict

forwards a request to different message-server (This function does not adds the meta-data info as send_request does).

Parameters:

request_msg (dict) – The request to forward.

send_msg(data: dict, **kwargs) None

sends a simple message as raw data, won’t wait for response

Parameters:

data (dict) – The data to send to server.

send_request(msg_type: str, data: dict, creation_time: datetime | None = None, response_required: bool = False) dict

Wrap the data into a message request and sent it to the robot message server

Parameters:
  • msg_type (str) – the type of message.

  • data (dict) – The message data to be sent to the robot message server.

  • creation_time (datetime, optional) – The time where the request is created. Defaults to now.

  • response_required (bool) – whether to wait for response, Default False.

movai_core_shared.core.secure module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Erez Zomer (erez@mov.ai) - 2022

movai_core_shared.core.secure.generate_secret_bytes(length: int = 32) bytes

The function generates a unique secret in bytes format,

Parameters:

length (int, optional) – the length of the secret. Defaults to 32.

Returns:

the generated secret.

Return type:

bytes

movai_core_shared.core.secure.generate_secret_string(length: int = 32) bytes

The function generates a unique secret in bytes format,

Parameters:

length (int, optional) – the length of the secret. Defaults to 32.

Returns:

the generated secret.

Return type:

bytes

movai_core_shared.core.securepassword module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Erez Zomer (erez@mov.ai) - 2022

class movai_core_shared.core.securepassword.SecurePassword(secret: str | None = None)

Bases: object

A class for securing password by encryption or hashing.

static create_hash(*args, **kwargs)

This function is encapsulates the decorated function and add the validation of the password.

Raises:
Returns:

a decorated function.

Return type:

callable

static create_salt() str

This function creat a random salt using SHA256 algorithm.

Returns:

a string representing the secure hash of the salt.

Return type:

str

static create_salted_hash(*args, **kwargs)

This function is encapsulates the decorated function and add the validation of the password.

Raises:
Returns:

a decorated function.

Return type:

callable

decrypt_password(cipher_text: bytes) str

Decrypts the given hash using the AES algorithm.

Parameters:

cipher_text (str) – The encrypted password to be decrypted.

Returns:

A plain text of the encrypted password.

Return type:

string

encrypt_password(plain_text: str) bytes

Encrypts the given text using the AES algorithm.

Parameters:

plain_text (str) – The password to be encrypted.

Returns:

the cipher text of the encrypted password.

Return type:

bytes

static extract_hash(combined_hash: bytes)
static extract_salt(combined_hash: bytes)
static verify_password(*args, **kwargs)

This function is encapsulates the decorated function and add the validation of the password.

Raises:
Returns:

a decorated function.

Return type:

callable

movai_core_shared.core.securepassword.password_checker(func)

This is function decorator for validating the password is in the correct type.

Parameters:

func (callable) – The function to be decorated

Module contents