Common classes#

Exception#

The class ScadeOneException is used to raise an exception. The message passed when raising the exception is passed to the Scade One logger ansys.scadeone.core.common.logger.ScadeOneLogger.

exception ansys.scadeone.core.common.exception.ScadeOneException(message: str, exc_info: bool = False)#

Bases: Exception

ScadeOne API Exception. When raising a ScadeOneException it is automatically logged. See ansys.scadeone.core.common.logger.ScadeOneLogger for more.

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

Logging#

The ScadeOneLogger class is a subclass of the logging.Logger class. As a singleton, the ScadeOneLogger class is initialized once and used throughout the application using the logger.LOGGER object or the logger application attribute.

The default logger is set to log to a file named pyscadeone.log and to the console. The log level is set to DEBUG.

One can set the logger to a different logger by setting the logger attribute as in the following example:

LOGGER.logger = logging.getLogger("MyLogger")
class ansys.scadeone.core.common.logger.ScadeOneLogger#

Bases: object

Class handling the singleton logger.

critical(msg: str, *args, **kwargs) None#

Log a message with severity CRITICAL on the logger.

debug(msg: str, *args, **kwargs) None#

Log a message with severity DEBUG on the logger.

error(msg: str, *args, **kwargs) None#

Log an error message with severity ERROR on the logger.

exception(msg: str, *args, **kwargs) None#

Log an exception message with severity ERROR on the logger.

info(msg: str, *args, **kwargs) None#

Log a message with severity INFO on the logger.

warning(msg: str, *args, **kwargs) None#

Log a message with severity WARNING on the logger.

property logger: Logger#

Return the logger instance. The internal logger can be set by setting the logger attribute.

Versioning#

The versioning module contains the version manager for the Scade One formats.

class ansys.scadeone.core.common.versioning.VersionManager#

Bases: object

Class managing the versions for the Scade One tools formats.

The version manager is used through the singleton FormatVersions instance.

check(format: str, version: str)#

Check if the version is supported for the format.

Parameters:
formatstr

Format name

versionstr

Version to be checked

Raises:
ScadeOneException

If the version is not supported for the format.

description(format: str)#

Get the description for the format.

Parameters:
formatstr

Format name

Returns:
str

Description

get_versions() str#

Get the versions as a document string.

Returns:
str

String containing the versions

load_versions(version_file: Path)#

Load the versions from the json file file.

Parameters:
version_filePath

JSON file containing the versions

Raises:
ScadeOneException

If the file is not found or if the file is not valid.

version(format: str)#

Get the version for the format.

Parameters:
formatstr

Format name

Returns:
str

Version

property formats: set#

Get the formats as a set of strings.