movai_core_shared package

Subpackages

Submodules

movai_core_shared.consts module

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

Developers: - Dor Marcous (Dor@mov.ai) - 2022

class movai_core_shared.consts.DeactivationType

Bases: object

AUTO_CLEARED = 'auto_cleared'
REQUESTED = 'requested'

movai_core_shared.envvars module

Environment variables.

movai_core_shared.envvars.DETACHED_PROCESS_OUTPUT

Where to forward logs from e.g. tools that run outside the entrypoint.

Type:

str

movai_core_shared.exceptions module

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

Developers: - Manuel Silva (manuel.silva@mov.ai) - 2020 - Tiago Paulino (tiago@mov.ai) - 2020 - Dor Marcous (Dor@mov.ai) - 2022

exception movai_core_shared.exceptions.AclObjectAlreadyExist(message: str)

Bases: AclObjectError

the required object is already found on DB.

exception movai_core_shared.exceptions.AclObjectDoesNotExist(message: str)

Bases: AclObjectError

the required object is not found on DB.

exception movai_core_shared.exceptions.AclObjectError(message: str)

Bases: MovaiException

a base class for AclObject model exceptions.

exception movai_core_shared.exceptions.AclObjectIDMismatch(message: str)

Bases: AclObjectError

The name and the ID of the required object are mismatched.

exception movai_core_shared.exceptions.AclObjectInvalidAttribute(message: str)

Bases: AclObjectError

The required attribute does id not defined in AclObject scheme.

exception movai_core_shared.exceptions.ActiveFlowError

Bases: MovaiException

Raise when the command requires an active flow

exception movai_core_shared.exceptions.AlreadyExist

Bases: MovaiException

Raised when something already exists.

exception movai_core_shared.exceptions.ArgumentError

Bases: MovaiException

The supplied argument is invalid.

exception movai_core_shared.exceptions.AuthorizationError(message: str)

Bases: LoginError

Failure to get access to the system.

exception movai_core_shared.exceptions.CommandError

Bases: MovaiException

Raise when the command does not exist

exception movai_core_shared.exceptions.ConfigurationDoesNotExist

Bases: DoesNotExist

The requested configuration could not be found.

exception movai_core_shared.exceptions.ConfigurationError

Bases: MovaiException

The configuration cannot be parsed.

exception movai_core_shared.exceptions.DoesNotExist

Bases: MovaiException

Raised when something is not found.

exception movai_core_shared.exceptions.DomainDoesNotExist(message: str)

Bases: LoginError

The required domain is not registered in the systm.

exception movai_core_shared.exceptions.HandlerNotFoundError

Bases: MovaiException

The message has no suitable handler.

exception movai_core_shared.exceptions.InitializationError

Bases: MovaiException

Failure to initialize an object.

exception movai_core_shared.exceptions.InvalidCredentials(message: str)

Bases: LoginError

Supplied credentials are incorrect.

exception movai_core_shared.exceptions.InvalidStructure

Bases: MovaiException

Raised when structure to be saved in DB is invalid.

exception movai_core_shared.exceptions.InvalidToken(message: str)

Bases: TokenError

Failed to get access token.

exception movai_core_shared.exceptions.LdapConfigAlreadyExist(message: str)

Bases: LdapConfigError

A configuration with the supplied name is already exist in DB.

exception movai_core_shared.exceptions.LdapConfigDoesNotExist(message: str)

Bases: LdapConfigError

the required configuration is not found on DB.

exception movai_core_shared.exceptions.LdapConfigError(message: str)

Bases: MovaiException

a base class for LdapConfig model exceptions.

exception movai_core_shared.exceptions.LdapConfigInvalidStructure(message: str)

Bases: LdapConfigError

a required parameter is missing in supplied LdapConfig dictionary.

exception movai_core_shared.exceptions.LdapConfigMissingParameter(message: str)

Bases: LdapConfigError

a required parameter is missing in supplied LdapConfig dictionary.

exception movai_core_shared.exceptions.LoginError(message: str)

Bases: MovaiException

A base class for login errors.

exception movai_core_shared.exceptions.MessageError

Bases: MovaiException

There are missing keys in the message.

exception movai_core_shared.exceptions.MessageFormatError

Bases: MessageError

There are missing keys in the message.

exception movai_core_shared.exceptions.MovaiException

Bases: Exception

General MovAI API exception occurred.

exception movai_core_shared.exceptions.NotSupported

Bases: MovaiException

The method is not supported for this version

exception movai_core_shared.exceptions.PasswordASCIIFormatError

Bases: MovaiException

The supplied password isn’t comprised of ascii symbols.

exception movai_core_shared.exceptions.PasswordComplexityError(message: str)

Bases: PasswordError

The password doesn’t comply with complexity settings.

exception movai_core_shared.exceptions.PasswordError(message: str)

Bases: MovaiException

a base class for password exceptions.

exception movai_core_shared.exceptions.PrimaryKeyError

Bases: MovaiException

The supplied key is in wrong format

exception movai_core_shared.exceptions.QueryError

Bases: MovaiException

Something is wrong with the metric.

exception movai_core_shared.exceptions.RemapValidationError

Bases: MovaiException

Remapping rules violation

exception movai_core_shared.exceptions.RestrictedPathError

Bases: MovaiException

The client tries to access restricted path.

exception movai_core_shared.exceptions.RobotRunning

Bases: MovaiException

Raised when an action cannot be performed because the robot is running.

exception movai_core_shared.exceptions.RoleAlreadyExist(message: str)

Bases: RoleError

the requested role is already found in DB.

exception movai_core_shared.exceptions.RoleDoesNotExist(message: str)

Bases: RoleError

the requested role is not found on DB.

exception movai_core_shared.exceptions.RoleError(message: str)

Bases: MovaiException

a base class for Role model exceptions.

exception movai_core_shared.exceptions.RunError

Bases: MovaiException

Run error elements exception

exception movai_core_shared.exceptions.SecretKeyAlreadyExist(message: str)

Bases: SecretKeyError

the requested secret key is already found in DB.

exception movai_core_shared.exceptions.SecretKeyDoesNotExist(message: str)

Bases: SecretKeyError

the requested secret key is not found on DB.

exception movai_core_shared.exceptions.SecretKeyError(message: str)

Bases: MovaiException

a base class for Role model exceptions.

exception movai_core_shared.exceptions.TimeError

Bases: MovaiException

The supplied time is not a timestamp

exception movai_core_shared.exceptions.TokenError(message: str)

Bases: LoginError

General Token error

exception movai_core_shared.exceptions.TokenExpired(message: str)

Bases: TokenError

Token’s signature has expired.

exception movai_core_shared.exceptions.TokenRevoked(message: str)

Bases: TokenError

Token have been revoked.

exception movai_core_shared.exceptions.TransitionException

Bases: MovaiException

Raised a GD_Node transition happens.

exception movai_core_shared.exceptions.UnknownRequestError

Bases: MovaiException

The request format is unknown.

exception movai_core_shared.exceptions.UserAlreadyExist(message: str)

Bases: UserError

The requested user is already exist in the system.

exception movai_core_shared.exceptions.UserDoesNotExist(message: str)

Bases: UserError

The requested user is not exist in the system.

exception movai_core_shared.exceptions.UserError(message: str)

Bases: MovaiException

A base class for user errors.

exception movai_core_shared.exceptions.UserPermissionsError(message: str)

Bases: UserError

The user’s permissions can’t be retrieved.

movai_core_shared.logger module

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

Developers: - Dor Marcous (dor@mov.ai) - 2022

class movai_core_shared.logger.Log

Bases: object

A static class to help create logger instances

LOG_FILE = '/opt/mov.ai/app/movai.log'
classmethod get_callback_logger(logger_name: str, node_name: str, callback_name: str) → LogAdapter

Gets the callback the logger.

Parameters:

logger_name (str) – The name of the logger.

Returns:

A logger with tags.

Return type:

LogAdapter

static get_logger(logger_name: str, stream_config=None)

Get a logger instance

classmethod get_user_logger(logger_name: str, **tags: dict) → LogAdapter

Add ‘user_log=True’ tag to the logger.

Parameters:

logger_name (str) – The name of the logger.

Returns:

A logger with tags.

Return type:

LogAdapter

static set_log_file(name: str)

Set the name of the file we write the log

class movai_core_shared.logger.StdOutHandler(color={10: '\x1b[1;34m', 20: '\x1b[1;37m', 30: '\x1b[1;33m', 40: '\x1b[31;1m', 50: '\x1b[41;1m'}, stream=None)

Bases: StreamHandler

emit(record)

Emit a record.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

movai_core_shared.logger.add_shared_handler_to_root()

Add handler to root so logs can be tailed and redirected to e.g. docker logs.

movai_core_shared.recovery module

Recovery file holds const and enum used by the recovery module.

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

Developers: - Dor Marcous (Dor@mov.ai) - 2023

class movai_core_shared.recovery.RecoveryStates(value)

Bases: Enum

Class for keeping recovery states. Values are stored in recovery_state fleet variable.

IN_RECOVERY = 2
NOT_AVAILABLE = 4
PUSHED = 3
READY = 1

Module contents

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

Developers: - Dor Marcous (Dor@mov.ai) - 2022

exception movai_core_shared.ActiveFlowError

Bases: MovaiException

Raise when the command requires an active flow

exception movai_core_shared.AlreadyExist

Bases: MovaiException

Raised when something already exists.

exception movai_core_shared.CommandError

Bases: MovaiException

Raise when the command does not exist

exception movai_core_shared.DoesNotExist

Bases: MovaiException

Raised when something is not found.

exception movai_core_shared.InvalidStructure

Bases: MovaiException

Raised when structure to be saved in DB is invalid.

class movai_core_shared.Log

Bases: object

A static class to help create logger instances

LOG_FILE = '/opt/mov.ai/app/movai.log'
classmethod get_callback_logger(logger_name: str, node_name: str, callback_name: str) → LogAdapter

Gets the callback the logger.

Parameters:

logger_name (str) – The name of the logger.

Returns:

A logger with tags.

Return type:

LogAdapter

static get_logger(logger_name: str, stream_config=None)

Get a logger instance

classmethod get_user_logger(logger_name: str, **tags: dict) → LogAdapter

Add ‘user_log=True’ tag to the logger.

Parameters:

logger_name (str) – The name of the logger.

Returns:

A logger with tags.

Return type:

LogAdapter

static set_log_file(name: str)

Set the name of the file we write the log

class movai_core_shared.LogAdapter(logger: Logger, **kwargs)

Bases: LoggerAdapter

A LogAdapter used to expose the logger inside a callback, we should not need to use this adapter outside a callback.

py_logger = Log.get_logger(“logger name”) logger = LogAdapter(py_logger, tag1=”value”, tag2=”value”)

Usage:

logger.debug(<message>, <tagKey>=<tagValue>, <tagKey>=<tagValue>…) logger.info(<message>, <tagKey>=<tagValue>, <tagKey>=<tagValue>…) logger.warning(<message>, <tagKey>=<tagValue>, <tagKey>=<tagValue>…) logger.error(<message>, <tagKey>=<tagValue>, <tagKey>=<tagValue>…) logger.critical(<message>, <tagKey>=<tagValue>, <tagKey>=<tagValue>…)

log(level, msg, *args, **kwargs)

Custom log func, adding traceback and stacklevel.

process(msg, kwargs)

Method called to extract the tags from the message.

exception movai_core_shared.MovaiException

Bases: Exception

General MovAI API exception occurred.

class movai_core_shared.RecoveryStates(value)

Bases: Enum

Class for keeping recovery states. Values are stored in recovery_state fleet variable.

IN_RECOVERY = 2
NOT_AVAILABLE = 4
PUSHED = 3
READY = 1
exception movai_core_shared.RobotRunning

Bases: MovaiException

Raised when an action cannot be performed because the robot is running.

exception movai_core_shared.TransitionException

Bases: MovaiException

Raised a GD_Node transition happens.