π― 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:
- Primary:
partprobe (if available)
- Fallback 1:
blockdev --rereadpt (works on most Linux systems)
- 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
- LabelFrame Import Missing: Added
LabelFrame to tkinter imports
- Partprobe Not Available: New fallback mechanism handles missing partprobe
- Device Locked Error: Added wait after unmounting before repartitioning
- Font Rendering Issues: Dynamic font detection eliminates unsupported font errors
- 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:
- No new dependencies required
- Automatic dependency resolution with detailed logging
- Run:
sudo python3 format_usb_gui.py
- Check
dependency_install_log.txt if issues occur
For Developers:
- Enhanced logging throughout dependency check
- System info available in About dialog for debugging
- Font system easily extensible for custom themes
- Clear fallback patterns for OS-specific differences
π Testing Recommendations
π 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