From 83e07b8f9bd2d897968b602ecb66f6653d5ae4e3 Mon Sep 17 00:00:00 2001 From: Jamil Hajjar Date: Wed, 6 Sep 2023 09:25:32 +0200 Subject: [PATCH] export logger (#100) --- src/ansys/tools/path/__init__.py | 2 ++ src/ansys/tools/path/path.py | 7 ++++++- tests/unit/test_path.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ansys/tools/path/__init__.py b/src/ansys/tools/path/__init__.py index e11ab433..2d0240dc 100644 --- a/src/ansys/tools/path/__init__.py +++ b/src/ansys/tools/path/__init__.py @@ -10,6 +10,7 @@ from ansys.tools.path.path import ( + LOG, SETTINGS_DIR, SUPPORTED_ANSYS_VERSIONS, change_default_mapdl_path, @@ -30,6 +31,7 @@ from ansys.tools.path.path import save_ansys_path # deprecated __all__ = [ + "LOG", "SETTINGS_DIR", "SUPPORTED_ANSYS_VERSIONS", "change_default_mapdl_path", diff --git a/src/ansys/tools/path/path.py b/src/ansys/tools/path/path.py index bc5410d2..9ee53509 100644 --- a/src/ansys/tools/path/path.py +++ b/src/ansys/tools/path/path.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from glob import glob import json -import logging as LOG # Temporal hack +import logging import os import re from typing import Callable, Dict, Literal, Optional, Tuple, Union @@ -11,6 +11,8 @@ from ansys.tools.path.misc import is_float, is_linux, is_windows +LOG = logging.getLogger(__name__) + PRODUCT_TYPE = Literal["mapdl", "mechanical"] SUPPORTED_VERSIONS_TYPE = Dict[int, str] @@ -107,6 +109,7 @@ def _get_default_linux_base_path() -> Optional[str]: """Get the default base path of the Ansys unified install on linux.""" for path in LINUX_DEFAULT_DIRS: + LOG.debug(f"Checking {path} as a potential ansys directory") if os.path.isdir(path): return path return None @@ -779,6 +782,8 @@ def _get_application_path( if exe_loc is not None: return exe_loc + LOG.debug(f"{product} path not found in config file") + try: exe_loc, exe_version = _find_installation(product, version) if (exe_loc, exe_version) != ("", ""): # executable not found diff --git a/tests/unit/test_path.py b/tests/unit/test_path.py index 00869a27..d7945337 100644 --- a/tests/unit/test_path.py +++ b/tests/unit/test_path.py @@ -1,4 +1,5 @@ import json +import logging import os import sys from unittest.mock import patch @@ -8,6 +9,7 @@ import pytest from ansys.tools.path import ( + LOG, SETTINGS_DIR, change_default_ansys_path, change_default_mapdl_path, @@ -25,6 +27,8 @@ version_from_path, ) +LOG.setLevel(logging.DEBUG) + VERSIONS = [202, 211, 231] STUDENT_VERSIONS = [201, 211]