| # - x - x - x - x - x - x - x - x - x - x - x - x - x - x - # | |
| # # | |
| # This file was created by: Alberto Palomo Alonso # | |
| # Universidad de Alcalá - Escuela Politécnica Superior # | |
| # # | |
| # - x - x - x - x - x - x - x - x - x - x - x - x - x - x - # | |
| # Import statements: | |
| import os | |
| import shutil | |
| import logging | |
| # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # | |
| def clear_logs(log_path: str): | |
| """ | |
| Clears all the files inside log_path path. | |
| Args: | |
| log_path (str): The file path to be clean. | |
| Raises: | |
| ValueError: If the log_path is not valid. | |
| """ | |
| # Close all loggers: | |
| logging.getLogger().handlers.clear() | |
| if os.path.exists(log_path): | |
| # Clear the directory if it exists | |
| shutil.rmtree(log_path) | |
| else: | |
| raise ValueError(f'Path {log_path} does not exist.') | |
| # - x - x - x - x - x - x - x - x - x - x - x - x - x - x - # | |
| # END OF FILE # | |
| # - x - x - x - x - x - x - x - x - x - x - x - x - x - x - # | |