movai_core_shared package
Subpackages
- movai_core_shared.common package
- movai_core_shared.core package
- Subpackages
- movai_core_shared.core.zmq package
- Submodules
- movai_core_shared.core.zmq.zmq_base module
- movai_core_shared.core.zmq.zmq_client module
- movai_core_shared.core.zmq.zmq_helpers module
- movai_core_shared.core.zmq.zmq_manager module
- movai_core_shared.core.zmq.zmq_publisher module
- movai_core_shared.core.zmq.zmq_server module
- movai_core_shared.core.zmq.zmq_subscriber module
- Module contents
- movai_core_shared.core.zmq package
- Submodules
- movai_core_shared.core.base_command module
- movai_core_shared.core.message_client module
- movai_core_shared.core.secure module
- movai_core_shared.core.securepassword module
- Module contents
- Subpackages
- movai_core_shared.messages package
- Submodules
- movai_core_shared.messages.alert_data module
- movai_core_shared.messages.command_data module
- movai_core_shared.messages.email_data module
- movai_core_shared.messages.general_data module
- movai_core_shared.messages.log_data module
- movai_core_shared.messages.metric_data module
AlertQueryContentAlertQueryContent.activation_dateAlertQueryContent.alert_idAlertQueryContent.argsAlertQueryContent.deactivation_dateAlertQueryContent.deactivation_typeAlertQueryContent.fleetAlertQueryContent.idAlertQueryContent.model_configAlertQueryContent.model_fieldsAlertQueryContent.robotAlertQueryContent.serviceAlertQueryContent.time
AlertQueryDataAlertQueryResponseGenericQueryResponseLogQueryContentLogQueryDataLogQueryResponseMetricDataMetricQueryDataMetricQueryRequestMetricQueryResponseMetricRequestQueryData
- movai_core_shared.messages.notification_data module
- movai_core_shared.messages.sms_data module
- movai_core_shared.messages.stress_data module
- movai_core_shared.messages.user_data module
- Module contents
Submodules
movai_core_shared.alert module
Alert query.
- class movai_core_shared.alert.AlertQuery
Bases:
BaseQueryQueryies alerts.
- async classmethod get(limit: int = 1000, offset: int = 0, robots: List[str] | None = None, from_date: int | str | None = None, to_date: int | str | None = None, order_by: str | None = None, order_dir: str | None = None) → AlertQueryResponse
Get alerts from message-server.
- Parameters:
limit – Maximum number of measurements to return.
offset – Query offset.
robots – List of robot names to filter.
from_date – Start date to filter.
to_date – End date to filter.
order_by – Field to order the measurements by.
order_dir – Direction of ordering.
- Returns:
The response containing the queried alerts.
- Return type:
movai_core_shared.base_query module
Base query.
- class movai_core_shared.base_query.BaseQuery
Bases:
objectA class for querying metrics.
- classmethod validate_datetime(value: int) → int
Validate if value is timestamp or datetime
- Parameters:
value (int) – The datetime to validate
- Raises:
ValueError – In case value isn’t a time format.
- Returns:
a timestamp value.
- Return type:
int
- classmethod validate_message(value: str) → str
Validates the message
- Parameters:
value (str) – A message to validate
- Raises:
ValueError – In case message is not a string.
- Returns:
The message.
- Return type:
str
- classmethod validate_value(filter_name: str, value: int) → int
Validates the limmit.
- Parameters:
filter_name (str) – Which filter called the validation function.
value (int) – The limit to validate.
alternate_value (int) – an alternative value in case of error.
- Raises:
ValueError – in case limit can not be casted to int.
- Returns:
The validated limit.
- Return type:
int
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
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:
AclObjectErrorthe required object is already found on DB.
- exception movai_core_shared.exceptions.AclObjectDoesNotExist(message: str)
Bases:
AclObjectErrorthe required object is not found on DB.
- exception movai_core_shared.exceptions.AclObjectError(message: str)
Bases:
MovaiExceptiona base class for AclObject model exceptions.
- exception movai_core_shared.exceptions.AclObjectIDMismatch(message: str)
Bases:
AclObjectErrorThe name and the ID of the required object are mismatched.
- exception movai_core_shared.exceptions.AclObjectInvalidAttribute(message: str)
Bases:
AclObjectErrorThe required attribute does id not defined in AclObject scheme.
- exception movai_core_shared.exceptions.ActiveFlowError
Bases:
MovaiExceptionRaise when the command requires an active flow
- exception movai_core_shared.exceptions.AlreadyExist
Bases:
MovaiExceptionRaised when something already exists.
- exception movai_core_shared.exceptions.ArgumentError
Bases:
MovaiExceptionThe supplied argument is invalid.
- exception movai_core_shared.exceptions.AuthorizationError(message: str)
Bases:
LoginErrorFailure to get access to the system.
- exception movai_core_shared.exceptions.CommandError
Bases:
MovaiExceptionRaise when the command does not exist
- exception movai_core_shared.exceptions.ConfigurationDoesNotExist
Bases:
DoesNotExistThe requested configuration could not be found.
- exception movai_core_shared.exceptions.ConfigurationError
Bases:
MovaiExceptionThe configuration cannot be parsed.
- exception movai_core_shared.exceptions.DBHandlerError
Bases:
MovaiExceptionGeneral exception in DBHandler.
- exception movai_core_shared.exceptions.DoesNotExist
Bases:
MovaiExceptionRaised when something is not found.
- exception movai_core_shared.exceptions.DomainDoesNotExist(message: str)
Bases:
LoginErrorThe required domain is not registered in the systm.
- exception movai_core_shared.exceptions.HandlerNotFoundError
Bases:
MovaiExceptionThe message has no suitable handler.
- exception movai_core_shared.exceptions.InitializationError
Bases:
MovaiExceptionFailure to initialize an object.
- exception movai_core_shared.exceptions.InvalidCredentials(message: str)
Bases:
LoginErrorSupplied credentials are incorrect.
- exception movai_core_shared.exceptions.InvalidStructure
Bases:
MovaiExceptionRaised when structure to be saved in DB is invalid.
- exception movai_core_shared.exceptions.InvalidToken(message: str)
Bases:
TokenErrorFailed to get access token.
- exception movai_core_shared.exceptions.LdapConfigAlreadyExist(message: str)
Bases:
LdapConfigErrorA configuration with the supplied name is already exist in DB.
- exception movai_core_shared.exceptions.LdapConfigDoesNotExist(message: str)
Bases:
LdapConfigErrorthe required configuration is not found on DB.
- exception movai_core_shared.exceptions.LdapConfigError(message: str)
Bases:
MovaiExceptiona base class for LdapConfig model exceptions.
- exception movai_core_shared.exceptions.LdapConfigInvalidStructure(message: str)
Bases:
LdapConfigErrora required parameter is missing in supplied LdapConfig dictionary.
- exception movai_core_shared.exceptions.LdapConfigMissingParameter(message: str)
Bases:
LdapConfigErrora required parameter is missing in supplied LdapConfig dictionary.
- exception movai_core_shared.exceptions.LoginError(message: str)
Bases:
MovaiExceptionA base class for login errors.
- exception movai_core_shared.exceptions.MessageError
Bases:
MovaiExceptionThere are missing keys in the message.
- exception movai_core_shared.exceptions.MessageFormatError
Bases:
MessageErrorThere are missing keys in the message.
- exception movai_core_shared.exceptions.MetricError
Bases:
MessageErrorSomething is wrong with the metric.
- exception movai_core_shared.exceptions.MovaiException
Bases:
ExceptionGeneral MovAI API exception occurred.
- exception movai_core_shared.exceptions.NotSupported
Bases:
MovaiExceptionThe method is not supported for this version
- exception movai_core_shared.exceptions.PasswordASCIIFormatError
Bases:
MovaiExceptionThe supplied password isn’t comprised of ascii symbols.
- exception movai_core_shared.exceptions.PasswordComplexityError(message: str)
Bases:
PasswordErrorThe password doesn’t comply with complexity settings.
- exception movai_core_shared.exceptions.PasswordError(message: str)
Bases:
MovaiExceptiona base class for password exceptions.
- exception movai_core_shared.exceptions.PrimaryKeyError
Bases:
MovaiExceptionThe supplied key is in wrong format
- exception movai_core_shared.exceptions.QueryError
Bases:
MovaiExceptionSomething is wrong with the metric.
- exception movai_core_shared.exceptions.RemapValidationError
Bases:
MovaiExceptionRemapping rules violation
- exception movai_core_shared.exceptions.RestrictedPathError
Bases:
MovaiExceptionThe client tries to access restricted path.
- exception movai_core_shared.exceptions.RobotRunning
Bases:
MovaiExceptionRaised when an action cannot be performed because the robot is running.
- exception movai_core_shared.exceptions.RoleAlreadyExist(message: str)
Bases:
RoleErrorthe requested role is already found in DB.
- exception movai_core_shared.exceptions.RoleDoesNotExist(message: str)
Bases:
RoleErrorthe requested role is not found on DB.
- exception movai_core_shared.exceptions.RoleError(message: str)
Bases:
MovaiExceptiona base class for Role model exceptions.
- exception movai_core_shared.exceptions.RunError
Bases:
MovaiExceptionRun error elements exception
- exception movai_core_shared.exceptions.SecretKeyAlreadyExist(message: str)
Bases:
SecretKeyErrorthe requested secret key is already found in DB.
- exception movai_core_shared.exceptions.SecretKeyDoesNotExist(message: str)
Bases:
SecretKeyErrorthe requested secret key is not found on DB.
- exception movai_core_shared.exceptions.SecretKeyError(message: str)
Bases:
MovaiExceptiona base class for Role model exceptions.
- exception movai_core_shared.exceptions.TimeError
Bases:
MovaiExceptionThe supplied time is not a timestamp
- exception movai_core_shared.exceptions.TokenError(message: str)
Bases:
LoginErrorGeneral Token error
- exception movai_core_shared.exceptions.TokenExpired(message: str)
Bases:
TokenErrorToken’s signature has expired.
- exception movai_core_shared.exceptions.TokenRevoked(message: str)
Bases:
TokenErrorToken have been revoked.
- exception movai_core_shared.exceptions.TransitionException
Bases:
MovaiExceptionRaised a GD_Node transition happens.
- exception movai_core_shared.exceptions.UnknownRequestError
Bases:
MovaiExceptionThe request format is unknown.
- exception movai_core_shared.exceptions.UserAlreadyExist(message: str)
Bases:
UserErrorThe requested user is already exist in the system.
- exception movai_core_shared.exceptions.UserDoesNotExist(message: str)
Bases:
UserErrorThe requested user is not exist in the system.
- exception movai_core_shared.exceptions.UserError(message: str)
Bases:
MovaiExceptionA base class for user errors.
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:
objectA 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:
- 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:
- static set_log_file(name: str)
Set the name of the file we write the log
- class movai_core_shared.logger.LogsQuery
Bases:
BaseQueryA class for querying logs
- async classmethod get_logs(limit=1000, offset=0, robots=None, services=None, level=None, message=None, fromDate=None, toDate=None, order_by=None, order_dir=None, **kwrargs) → LogQueryResponse
Get logs from message-server
- class movai_core_shared.logger.RemoteHandler
Bases:
StreamHandlerThis class implemets a log handler which sends sends the data to message server for logging in influxdb.
- emit(record)
Builds a valid log message request from the python log record and send it to the local message server
- Parameters:
record – The Python log message data record
- 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.logger.get_remote_handler(log_level=0)
Create a RemoteHandler object and return it
- Parameters:
log_level – defines the remote logger log level default value is info
Returns: ReomoteLogger object
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
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:
MovaiExceptionRaise when the command requires an active flow
- exception movai_core_shared.AlreadyExist
Bases:
MovaiExceptionRaised when something already exists.
- exception movai_core_shared.CommandError
Bases:
MovaiExceptionRaise when the command does not exist
- exception movai_core_shared.DoesNotExist
Bases:
MovaiExceptionRaised when something is not found.
- exception movai_core_shared.InvalidStructure
Bases:
MovaiExceptionRaised when structure to be saved in DB is invalid.
- class movai_core_shared.Log
Bases:
objectA 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:
- 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:
- 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:
LoggerAdapterA 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:
ExceptionGeneral MovAI API exception occurred.
- class movai_core_shared.RecoveryStates(value)
Bases:
EnumClass 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:
MovaiExceptionRaised when an action cannot be performed because the robot is running.
- exception movai_core_shared.TransitionException
Bases:
MovaiExceptionRaised a GD_Node transition happens.