diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a3c308e..91a8b82d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Valid subsections within a version are: Things to be included in the next release go here. +### Added + +- Added a new parameter to the `create_visa_connection()` function which can be used to turn down the verbosity of the printouts to stdout during a reboot from `ERROR` to `DEBUG` to avoid cluttering the console with unnecessary failures while the device is still rebooting. + --- ## v3.1.1 (2025-02-04) diff --git a/pyproject.toml b/pyproject.toml index e51f3b69..40bc6e3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,7 +82,7 @@ libusb-package = "^1.0.26.0,!=1.0.26.2" # 1.0.26.2 doesn't work with Python 3.1 packaging = "^24.0" psutil = "^6.0.0" pyserial = "^3.5" -python = "^3.8" # This is the main Python version requirement +python = "^3.8,!=3.9.0,!=3.9.1" # This is the main Python version requirement, the excluded versions of Python had major bugs and shouldn't be used python-dateutil = "^2.8.2" pyusb = "^1.2.1" pyvicp = "^1.1.0" diff --git a/src/tm_devices/device_manager.py b/src/tm_devices/device_manager.py index d0f43824..4fdec18b 100644 --- a/src/tm_devices/device_manager.py +++ b/src/tm_devices/device_manager.py @@ -1047,8 +1047,6 @@ def open(self) -> bool: _logger.info("Opening Connections to Devices") for device_name, device_config in self.__config.devices.items(): self.__create_device(device_name, device_config, 3) - if self.__setup_cleanup_enabled: - self.cleanup_all_devices() self.__is_open = True self._suppress_protection = False diff --git a/src/tm_devices/driver_mixins/device_control/pi_control.py b/src/tm_devices/driver_mixins/device_control/pi_control.py index 54fa70f6..a54e5357 100644 --- a/src/tm_devices/driver_mixins/device_control/pi_control.py +++ b/src/tm_devices/driver_mixins/device_control/pi_control.py @@ -1028,6 +1028,7 @@ def _open(self) -> bool: self._visa_resource = create_visa_connection( self._config_entry, visa_library=self._visa_library_path, + verbose_connection_failure_logging=False, ) opened = True if iteration < 1 and not bool( diff --git a/src/tm_devices/helpers/functions.py b/src/tm_devices/helpers/functions.py index f40f9b0a..e53f62b1 100644 --- a/src/tm_devices/helpers/functions.py +++ b/src/tm_devices/helpers/functions.py @@ -303,6 +303,7 @@ def create_visa_connection( *, retry_connection: bool = False, second_connection_attempt_delay: int = 60, + verbose_connection_failure_logging: bool = True, ) -> MessageBasedResource: """Create a VISA resource. @@ -314,6 +315,8 @@ def create_visa_connection( between each attempt. second_connection_attempt_delay: The number of seconds to wait in between the first and second connection attempts when `retry_connection=True`. + verbose_connection_failure_logging: Indicates if the connections failures should be logged + with an ERROR level. If False, the failures will be logged with a DEBUG level. Returns: A VISA resource that can be passed into the device driver. @@ -321,6 +324,7 @@ def create_visa_connection( Raises: ConnectionError: The VISA connection couldn't be created to the device. """ + failure_logging_level = logging.ERROR if verbose_connection_failure_logging else logging.DEBUG # Set up the VISA resource that will be used for communicating with the VISA device resource_expression = device_config_entry.get_visa_resource_expression() try: @@ -351,8 +355,9 @@ def create_visa_connection( f" using the resource expression '{resource_expression}'" f" and the {repr(visa_library) if visa_library else 'default'} VISA library" ) - _logger.error(error_message) # noqa: TRY400 - _logger.error( # noqa: TRY400 + _logger.log(failure_logging_level, error_message) + _logger.log( + failure_logging_level, "1st exception: %s.%s: %s", error_1.__class__.__module__, error_1.__class__.__qualname__, @@ -379,14 +384,16 @@ def create_visa_connection( f" using the resource expression '{resource_expression}'" f" and the {repr(visa_library) if visa_library else 'default'} VISA library" ) - _logger.error(error_message) # noqa: TRY400 - _logger.error( # noqa: TRY400 + _logger.log(failure_logging_level, error_message) + _logger.log( + failure_logging_level, "1st exception: %s.%s: %s", error_1.__class__.__module__, error_1.__class__.__qualname__, error_1, ) - _logger.error( # noqa: TRY400 + _logger.log( + failure_logging_level, "2nd exception: %s.%s: %s:", error_2.__class__.__module__, error_2.__class__.__qualname__,