Beispiel #1
0
def _handle_missing_files(paths, missing_files):
    """
    Handle any missing files identified for a given image. This will log an error, which saves the error image, and
    sends an error-email, if email sending is enabled.

    :param paths: Paths object representing the input image
    :type paths: src.io.TreeWalker.Paths
    :param missing_files: List of missing files
    :type missing_files: list of str
    """
    current_logger_state = LOGGER.get_state()
    LOGGER.set_state(paths)
    LOGGER.error(
        __name__,
        f"Missing output files {missing_files} for image: {paths.input_file}",
        save=True,
        email=True,
        email_mode="error")
    LOGGER.set_state(current_logger_state)
Beispiel #2
0
    def handle_error(self, err):
        """
        Handle an exception raised by an async worker.

        :param err: Exception raised by the worker
        :type err: BaseException
        """
        # Get the current state of the logger
        current_logger_state = LOGGER.get_state()

        # Set the state of the logger to reflect the failed image.
        LOGGER.set_state(self.paths)
        # Log the error
        LOGGER.error(__name__,
                     self.error_message.format(
                         image_path=self.paths.input_file, err=str(err)),
                     save=False,
                     email=False)
        # Reset the state
        LOGGER.set_state(current_logger_state)