Skip to content

V2.0.1

Latest

Choose a tag to compare

@gevin456 gevin456 released this 07 Feb 09:23
c8c5b66

🎯 Major Features Added

1. Dynamic Font Detection & Compatibility

  • Added get_compatible_font() function that automatically detects available system fonts
  • Fallback chain: Ubuntu β†’ DejaVu Sans β†’ Liberation Sans β†’ Noto Sans β†’ Helvetica β†’ Arial β†’ System Default
  • Eliminates "Segoe UI" (Windows-only font) hard-coding
  • Works seamlessly across all Linux desktop environments
  • Impact: Application now renders properly on all Raspberry Pi OS versions and lightweight desktop managers

2. Robust Package Dependency Management

  • Enhanced check_and_install_dependencies() with support for package name variations
  • exFAT Support: Handles both exfat-fuse (Trixie) and exfat-utils (older versions)
  • Fallback Installation: Individual package installation with timeout handling (60s for update, 120s per package)
  • Graceful Degradation: Doesn't fail if optional packages unavailable; only requires critical tools (lsblk, parted, mkfs.*)
  • Better Error Logging: Detailed dependency install log for troubleshooting

3. System Information Detection

  • Added get_system_info() function to detect:
    • Linux distribution name and version
    • Python version
    • Machine architecture
    • Reads from /etc/os-release for accurate distro info
  • Enhanced About Dialog: Displays system compatibility information
    • Shows detected OS, Python version, architecture
    • Lists available filesystems
    • Useful for bug reporting and debugging

4. Intelligent Partition Table Probing

  • Replaced single partprobe call with robust probe_partition_table() function
  • Multi-level Fallback Strategy:
    1. Primary: partprobe (if available)
    2. Fallback 1: blockdev --rereadpt (works on most Linux systems)
    3. Fallback 2: Kernel automatic reload with 2-second wait
  • Benefit: Works on systems where partprobe package isn't installed
  • Prevents "device busy" errors on partition operations

5. Improved Device Mounting & Unmounting

  • Added 2-second delay after unmounting to allow kernel cleanup
  • Proper umount sequence in format_disk() and create_single_partition()
  • Prevents race conditions with device locking
  • Impact: Eliminates "Partitioning failed" errors from device being in-use

πŸ”§ Technical Improvements

Error Handling & Robustness

  • Added subprocess timeout handling (60s for apt-get update, 120s for package install)
  • Better exception handling throughout partition/format operations
  • Informative error messages for debugging
  • Graceful fallbacks when optional tools unavailable

Font System Refactoring

  • Replaced 19+ hardcoded ('Segoe UI', ...) references with dynamic font variables
  • Created font hierarchy: font_title, font_heading, font_normal, font_small, font_monospace
  • Single point of control for all UI fonts

Dependency Mapping

  • Binary-to-package mapping supports multiple package names per tool
  • Better handling of distro-specific package names
  • Clear logging of dependency installation progress

πŸ“‹ Detailed Changes by Component

check_and_install_dependencies()

# Old: Single package map
# New: Binary-to-packages mapping with fallback support
bin_to_packages = {
    'parted': ['parted'],
    'mkfs.exfat': ['exfat-fuse', 'exfat-utils'],  # Handles both versions
    # ... more tools
}

# Individual package installation with timeout handling
for pkg in missing_pkgs:
    subprocess.run([...], timeout=120)

probe_partition_table() (NEW)

  • Replaces hard-coded partprobe with intelligent fallback
  • Eliminates dependency on specific partition tools
  • Provides clear logging of which method was used

get_compatible_font() (NEW)

  • Detects available system fonts
  • Returns best available font or system default
  • Tested compatible with:
    • Raspberry Pi OS (all versions)
    • Ubuntu/Debian
    • Lightweight desktop managers (LXDE, Openbox)

get_system_info() (NEW)

  • Reads /etc/os-release for distro detection
  • Captures Python version, machine architecture
  • Used in About dialog for system compatibility info

Font Variable Updates (19 replacements)

  • font_title = Dynamic title font (16pt, bold)
  • font_heading = Section headers (10pt, bold)
  • font_normal = Standard text (9pt)
  • font_small = Small text (8pt)
  • font_monospace = Code/log display (Courier New or fallback)

πŸ› Bug Fixes

  1. LabelFrame Import Missing: Added LabelFrame to tkinter imports
  2. Partprobe Not Available: New fallback mechanism handles missing partprobe
  3. Device Locked Error: Added wait after unmounting before repartitioning
  4. Font Rendering Issues: Dynamic font detection eliminates unsupported font errors
  5. Package Installation Timeouts: Added timeout handling for slow systems

πŸ“¦ Version Compatibility

Tested With:

  • βœ… Raspberry Pi OS Bullseye
  • βœ… Raspberry Pi OS Bookworm
  • βœ… Raspberry Pi OS Trixie
  • βœ… Ubuntu 20.04+
  • βœ… Debian 10+

Package Support:

  • exFAT: Both exfat-fuse (Trixie+) and exfat-utils (older)
  • Partition Tools: partprobe, blockdev, or kernel auto-reload
  • Filesystems: ext4, FAT32, exFAT, NTFS, XFS, Btrfs

πŸ“ Code Statistics

  • Functions Added: 2 (get_compatible_font, get_system_info, probe_partition_table)
  • Lines Modified: ~60+ including font updates, error handling, dependency handling
  • Breaking Changes: None (backward compatible)
  • New Dependencies: None (all optional, graceful fallback)

πŸš€ Deployment Notes

For Users:

  1. No new dependencies required
  2. Automatic dependency resolution with detailed logging
  3. Run: sudo python3 format_usb_gui.py
  4. Check dependency_install_log.txt if issues occur

For Developers:

  1. Enhanced logging throughout dependency check
  2. System info available in About dialog for debugging
  3. Font system easily extensible for custom themes
  4. Clear fallback patterns for OS-specific differences

πŸ“‹ Testing Recommendations

  • Test on Bullseye (older environment)
  • Test on Bookworm (current stable)
  • Test on Trixie (newest)
  • Test without partprobe installed
  • Test without exfat-utils (upgrade to exfat-fuse)
  • Test font rendering on lightweight desktop (LXDE, Openbox)
  • Test dependency installation on fresh Raspberry Pi OS
  • Test large ISO writing (>4GB for Windows 11)

πŸ“„ Version Details

  • Version: 2.0.1
  • Release Date: February 7, 2026
  • Status: Stable
  • Compatibility: All Raspberry Pi OS versions + Debian/Ubuntu-based systems
  • Python Required: 3.7+

πŸ”— Related Issues

  • Fixes: "Partitioning failed: device busy" error
  • Fixes: "LabelFrame not defined" error
  • Fixes: Font rendering on various Linux distributions
  • Improved: Dependency detection and installation on different distros

πŸ’‘ Future Improvements

  • Add GUI theme selection
  • Support for ARM-specific optimizations
  • UEFI/BIOS detection for better boot configuration
  • Advanced partition layout options (multiple partitions)
  • Device health check (SMART for HDDs)
  • Automatic backup before formatting