smartinspectpython.sisessionmanager

@export
class SISessionManager:

Manages and configures session instances.

This class manages and configures a list of sessions. Sessions can be configured and added to the list with the Add method. To lookup a stored session, you can use Get. To remove an existing session from the list, call Delete.

Stored sessions will be reconfigured if LoadConfiguration has been called and contains corresponding session entries.

Threadsafety:

This class is fully thread-safe.

SISessionManager()

Initializes a new instance of the class.

PREFIX: str = 'session.'
PREFIX_LEN: int = 8

Specifies the default property values for new sessions.

This property lets you specify the default property values for new sessions which will be passed to the Add method. Please see the Add method for details. For information about the available session properties, please refer to the documentation of the Session class.

def Add( self, session: smartinspectpython.sisession.SISession, store: bool) -> None:

Configures a passed session instance and optionally saves it for later access.

Arguments:
  • session (SISession): The session to configure and to save for later access, if desired.
  • store (bool): Indicates if the passed session should be stored for later access.

This method configures the passed session with the default session properties as specified by the Defaults property. This default configuration can be overridden on a per-session basis by loading the session configuration with the LoadConfiguration method.

If the 'store' parameter is true, the passed session is stored for later access and can be retrieved with the Get method. To remove a stored session from the internal list, call Delete.

If this method is called multiple times with the same session name, then the Get method operates on the session which got added last. If the session parameter is null, this method does nothing.

def Assign( self, session: smartinspectpython.sisession.SISession, info: smartinspectpython.sisessioninfo.SISessionInfo) -> None:

Assigns property values to a session instance from stored session information.

Arguments:
  • session (SISession): Session to assign property values to.
  • info (SISessionInfo): Session information to retrieve property values from.
def Clear(self) -> None:

Clears the configuration of this session manager and removes all sessions from the internal lookup table.

def Configure( self, session: smartinspectpython.sisession.SISession, sessionName: str) -> None:

Configures the specified session from stored session information.

Arguments:
  • session (SISession): Session to configure.
  • sessionName (str): Name to retrieve session information properties from.
def Delete(self, session: smartinspectpython.sisession.SISession) -> None:

Removes a session from the internal list of sessions.

Arguments:
  • session (SISession): The session to remove from the lookup table of sessions.

This method removes a session which has previously been added with the Add method. After this method returns, the Get method returns null when called with the same session name unless a different session with the same name has been added.

This method does nothing if the supplied session argument is null.

def Get(self, sessionName: str) -> smartinspectpython.sisession.SISession:

Returns a previously added session.

Arguments:
  • (str): The name of the session to lookup and return.
Returns:

The requested session or null if the supplied name of the session is unknown.

Raises:
  • SIArgumentNullException: Thrown if the supplied sessionName is null, and a "Main" session does not exist.

This method returns a session which has previously been added with the Add method and can be identified by the supplied name parameter. If the requested session is unknown then this method returns null.

If sessionName is null, then the default "Main" session is returned if one exists.

Note that the behavior of this method can be unexpected in terms of the result value if multiple sessions with the same name have been added. In this case, this method returns the session which got added last and not necessarily the session which you expect.

Adding multiple sessions with the same name should therefore be avoided.

def LoadConfiguration(self, config: smartinspectpython.siconfiguration.SIConfiguration) -> None:

Loads the configuration properties of this session manager.

Arguments:
  • config (SIConfiguration): The SIConfiguration object to load the configuration from.

This method loads the configuration of this session manager from the passed SIConfiguration object. Sessions which have already been stored or will be added with Add will automatically configured with the new properties if the passed SIConfiguration object contains corresponding session entries. Moreover, this method also loads the default session properties which will be applied to all sessions which are passed to Add.

Please see the SmartInspect.LoadConfiguration method for details on how session entries and session defaults look like.

def LoadDefaults(self, config: smartinspectpython.siconfiguration.SIConfiguration) -> None:

Loads the configuration session default properties of this session manager.

Arguments:
  • config (SIConfiguration): The SIConfiguration object to load the configuration from.

This method will only process "SessionDefaults.x" lines, and will ignore the SmartInspect object configuration and "Session.x.x" lines.

def LoadInfo( self, name: str, config: smartinspectpython.siconfiguration.SIConfiguration) -> smartinspectpython.sisessioninfo.SISessionInfo:

Loads the configuration session instance properties of a defined session in this session manager.

Arguments:
  • name (str): The session name.
  • config (SIConfiguration): The SIConfiguration object to load the configuration from.
Returns:

A SISessionInfo object with session information.

def LoadInfos(self, config: smartinspectpython.siconfiguration.SIConfiguration) -> None:

Loads the configuration session instance properties of all defined sessions in this session manager.

Arguments:
  • (SIConfiguration): The SIConfiguration object to load the configuration from.

This method will only process the "session.x.x" configuration lines, and will ignore the SmartInspect object configuration and SessionDefaults lines.

def Update( self, session: smartinspectpython.sisession.SISession, toName: str, fromName: str) -> None:

Updates an entry in the internal lookup table of sessions.

Arguments:
  • session (SISession): The session whose name has changed and whose entry should be updated.
  • toName (str): The new name of the session.
  • fromName (str): The old name of the session.

Once the name of a session has changed, this method is called to update the internal session lookup table. The 'to' argument specifies the new name and 'from' the old name of the session. After this method returns, the new name can be passed to the Get method to lookup the supplied session.