Spaces:
Running
Running
Jake Reardon
Initial implementation of MLSE Player 3D Generator with SAM 3D Body integration
f0c79f8
| import os | |
| import logging | |
| from typing import Dict, Any | |
| # Set up logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def ensure_directories(): | |
| """ | |
| Ensure required directories exist. | |
| """ | |
| dirs = ["outputs", "temp"] | |
| for dir_path in dirs: | |
| os.makedirs(dir_path, exist_ok=True) | |
| logger.info(f"Ensured directory exists: {dir_path}") | |
| def cleanup_temp_files(): | |
| """ | |
| Clean up temporary files that are no longer needed. | |
| """ | |
| try: | |
| import glob | |
| import time | |
| # Delete files in temp directory that are older than 1 hour | |
| current_time = time.time() | |
| one_hour_ago = current_time - 3600 | |
| for file_path in glob.glob("temp/*"): | |
| if os.path.isfile(file_path): | |
| file_stats = os.stat(file_path) | |
| if file_stats.st_mtime < one_hour_ago: | |
| os.remove(file_path) | |
| logger.info(f"Deleted old temp file: {file_path}") | |
| except Exception as e: | |
| logger.error(f"Error cleaning up temp files: {str(e)}") |