From cfd5decd6a5414a4bfe13bd74151b3b56c560e6b Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Fri, 14 Oct 2022 08:56:31 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Josh A. Mitchell --- openff/toolkit/utils/openeye_wrapper.py | 14 +++++++------- openff/toolkit/utils/toolkit_registry.py | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openff/toolkit/utils/openeye_wrapper.py b/openff/toolkit/utils/openeye_wrapper.py index 3c3cc49dc..76281e50c 100644 --- a/openff/toolkit/utils/openeye_wrapper.py +++ b/openff/toolkit/utils/openeye_wrapper.py @@ -146,10 +146,14 @@ def __init__(self): if self._is_installed is False: raise ToolkitUnavailableException( "OpenEye Toolkits are not installed." - "{self._toolkit_installation_instructions}" + + self._toolkit_installation_instructions ) if self._is_licensed is False: - raise LicenseError(self._toolkit_license_instructions) + raise LicenseError( + "The OpenEye Toolkits are found to be installed but not licensed and " + + "therefore will not be used.\n" + + self._toolkit_license_instructions + ) from openeye import __version__ as openeye_version @@ -158,7 +162,7 @@ def __init__(self): @classmethod def _check_licenses(cls) -> bool: """Check license of all known OpenEye tools. Returns True if any are found - to be licensed, False if any are not.""" + to be licensed, False if all are not.""" for tool, license_func in cls._license_functions.items(): try: module = importlib.import_module("openeye." + tool) @@ -199,10 +203,6 @@ def is_available(cls): cls._is_available = True else: cls._is_available = False - logger.warning( - "The OpenEye Toolkits are found to be installed but not licensed and " - "therefore will not be used." - ) cls._is_available = cls._is_installed and cls._is_licensed return cls._is_available diff --git a/openff/toolkit/utils/toolkit_registry.py b/openff/toolkit/utils/toolkit_registry.py index b244bd74f..cb1fe1a08 100644 --- a/openff/toolkit/utils/toolkit_registry.py +++ b/openff/toolkit/utils/toolkit_registry.py @@ -164,12 +164,12 @@ def register_toolkit(self, toolkit_wrapper, exception_if_unavailable=True): try: toolkit_wrapper = toolkit_wrapper() - # This exception can only be raised by OpenEyeToolkitWrapper - except LicenseError as openeye_exception: + # This exception can be raised by OpenEyeToolkitWrapper + except LicenseError as license_exception: if exception_if_unavailable: - raise ToolkitUnavailableException(openeye_exception) + raise ToolkitUnavailableException(license_exception.msg) else: - logger.warning(openeye_exception) + logger.warning(license_exception) except ToolkitUnavailableException: msg = "Unable to load toolkit '{}'. ".format( toolkit_wrapper._toolkit_name