Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Raise an exception if license is inaccessible #3316

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/ansys/fluent/core/launcher/error_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
"""Provides a module for customized error handling."""

import os

from ansys.fluent.core.exceptions import InvalidArgument
from ansys.fluent.core.launcher import launcher_utils
from ansys.fluent.core.utils.fluent_version import FluentVersion


class InaccessibleAnsysLicense(RuntimeError):
"""Raised when license is inaccessible."""

def __init__(self):
super().__init__(
"Enable license server in `Licensing Settings` application and set `ANSYSLMD_LICENSE_FILE` environment variable correctly."
)


def _check_license():
if not os.getenv("ANSYSLMD_LICENSE_FILE", None):
hpohekar marked this conversation as resolved.
Show resolved Hide resolved
raise InaccessibleAnsysLicense()


class InvalidPassword(ValueError):
"""Raised when password is invalid."""

Expand Down
2 changes: 2 additions & 0 deletions src/ansys/fluent/core/launcher/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import ansys.fluent.core as pyfluent
from ansys.fluent.core.fluent_connection import FluentConnection
from ansys.fluent.core.launcher.container_launcher import DockerLauncher
from ansys.fluent.core.launcher.error_handler import _check_license
from ansys.fluent.core.launcher.launcher_utils import _confirm_watchdog_start
from ansys.fluent.core.launcher.pim_launcher import PIMLauncher
from ansys.fluent.core.launcher.pyfluent_enums import (
Expand Down Expand Up @@ -261,6 +262,7 @@ def launch_fluent(
The allocated machines and core counts are queried from the scheduler environment and
passed to Fluent.
"""
_check_license()
hpohekar marked this conversation as resolved.
Show resolved Hide resolved
if env is None:
env = {}

Expand Down