fix: narrow bare except blocks to specific exception types (#282)

Replace 6 bare `except:` blocks with targeted exception types:
- logo_downloader.py: OSError for file removal, (OSError, IOError) for font loading
- layout_manager.py: (ValueError, TypeError, KeyError, IndexError) for format string
- app.py: (OSError, ValueError) for CPU temp, (SubprocessError, OSError) for systemctl, (KeyError, TypeError, ValueError) for config parsing

Co-authored-by: 5ymb01 <5ymb01@users.noreply.github.com>
Co-authored-by: 5ymb01 <noreply@github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
5ymb01
2026-03-20 15:00:12 -04:00
committed by GitHub
parent f718305886
commit f3e7c639ba
3 changed files with 7 additions and 7 deletions

View File

@@ -238,7 +238,7 @@ class LayoutManager:
# Format the text
try:
text = format_str.format(value=value)
except:
except (ValueError, TypeError, KeyError, IndexError):
text = str(value)
self.display_manager.draw_text(text, x, y, color)

View File

@@ -237,7 +237,7 @@ class LogoDownloader:
logger.error(f"Downloaded file for {team_abbreviation} is not a valid image or conversion failed: {e}")
try:
os.remove(filepath) # Remove invalid file
except:
except OSError:
pass
return False
@@ -642,10 +642,10 @@ class LogoDownloader:
# Try to load a font, fallback to default
try:
font = ImageFont.truetype("assets/fonts/PressStart2P-Regular.ttf", 12)
except:
except (OSError, IOError):
try:
font = ImageFont.load_default()
except:
except (OSError, IOError):
font = None
# Draw team abbreviation