Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 1.99 KB

File metadata and controls

65 lines (50 loc) · 1.99 KB

Email Module Refactoring

Overview

The email functionality has been refactored to eliminate code duplication between the command-line and GUI versions of the media manager.

Changes Made

New Shared Module

  • email_utils.py - Centralized email functionality for both CLI and GUI applications

Updated Files

  • generate_missing_media_list.py - Now uses shared email module
  • media_manager_gui.py - Now uses shared email module
  • email_debug_test.py - Updated to use new EmailConfig class

Benefits

✅ Eliminated Code Duplication

  • Single source of truth for email functionality
  • Fixes only need to be applied in one place
  • Consistent behavior across CLI and GUI

✅ Better Configuration Management

  • Unified EmailConfig class
  • Support for both hardcoded (CLI) and config file (GUI) approaches
  • Validation of email configuration

✅ Improved Maintainability

  • Cleaner, more modular code
  • Easier to add new email features
  • Better error handling and logging

Usage

Command Line Script

The CLI script automatically uses hardcoded email settings that can be edited in email_utils.py:

# Users update these values in email_utils.py
def create_email_config_hardcoded():
    return EmailConfig(
        sender_name="YOUR_NAME_HERE",
        sender_email="YOUR_EMAIL_HERE",
        receiver_email="RECEIVER_EMAIL_HERE",
        password="PASSWORD_HERE",
        smtp_server="smtp.server.com",
        smtp_port=587
    )

GUI Application

The GUI continues to use media_manager_config.json for configuration through the interface.

Debug Script

The debug script now uses the shared module and EmailConfig class for consistency.

Backward Compatibility

  • GUI configuration files remain unchanged
  • Command-line usage remains the same
  • All existing functionality preserved

Future Improvements

  • Could standardize both CLI and GUI to use config files
  • Could add support for additional email providers
  • Could add email templating capabilities