LicenseManager#

class ansys.mechanical.core.embedding.license_manager.LicenseManager(app)#

Class to manage licenses in Ansys Mechanical.

This class provides methods to enable, disable, and check the status of licenses. It also allows for moving licenses to specific indices in the license preference list. It is initialized with an instance of the Ansys Mechanical application.

Overview#

get_all_licenses

Return list of all licenses.

get_license_status

Return status of the specific license.

set_license_status

Set the status of a license and save the preference.

show

Print all active licenses.

disable_session_license

Disable active license for current session.

enable_session_license

Enable license(s) for the current session.

move_to_index

Move a license preference.

reset_preference

Reset the license preference.

Import detail#

from ansys.mechanical.core.embedding.license_manager import LicenseManager

Method detail#

LicenseManager.get_all_licenses() list[str]#

Return list of all licenses.

LicenseManager.get_license_status(license_name: str) Ansys.Mechanical.DataModel.Enums.LicenseStatus#

Return status of the specific license.

Parameters:
license_namestr

Name of the license to check.

Returns:
“Ansys.Mechanical.DataModel.Enums.LicenseStatus”

The status of the license.

LicenseManager.set_license_status(license_name: str, status: bool) None#

Set the status of a license and save the preference.

Parameters:
license_namestr

Name of the license to set the status for.

statusbool

True to enable the license, False to disable it.

LicenseManager.show() None#

Print all active licenses.

LicenseManager.disable_session_license() None#

Disable active license for current session.

LicenseManager.enable_session_license(license: str | List[str] | None = None) None#

Enable license(s) for the current session.

Parameters:
licenseOptional[Union[str, List[str]]], optional

If None, activates the first enabled license in the priority order. If a string, activates that specific license. If a list of strings, activates all specified licenses in the order provided.

LicenseManager.move_to_index(license_name: str, location: int) None#

Move a license preference.

Move license to zero-based index location in the license preference list. This is useful for setting the preferred license location.

Parameters:
license_namestr

License name.

locationint

Location to move the license to.

Examples

Move Ansys Mechanical Premium to the first location.

>>> license_manager = LicenseManager(app)
>>> license_manager.move_to_index('Ansys Mechanical Premium', 0)
LicenseManager.reset_preference() None#

Reset the license preference.

This method will reset the license location order and the status of all licenses to the default state.