mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-16 07:03:00 +00:00
debug(nhl): Add logging to investigate resize/AttributeError issue
This commit is contained in:
@@ -327,11 +327,17 @@ def create_scorebug_image(game_details):
|
|||||||
away_logo_rgba = Image.open(game_details["away_logo_path"]).convert("RGBA")
|
away_logo_rgba = Image.open(game_details["away_logo_path"]).convert("RGBA")
|
||||||
# Resize and reassign, instead of in-place thumbnail
|
# Resize and reassign, instead of in-place thumbnail
|
||||||
away_logo_rgba = away_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
away_logo_rgba = away_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
||||||
|
# --- Debugging ---
|
||||||
|
logging.debug(f"[NHL Debug] Away upcoming Type after resize: {type(away_logo_rgba)}")
|
||||||
|
logging.debug(f"[NHL Debug] Away upcoming Has width attr: {hasattr(away_logo_rgba, 'width')}")
|
||||||
|
logging.debug(f"[NHL Debug] Away upcoming Has height attr: {hasattr(away_logo_rgba, 'height')}")
|
||||||
|
# --- End Debugging ---
|
||||||
|
|
||||||
paste_x = away_logo_pos[0]
|
paste_x = away_logo_pos[0]
|
||||||
paste_y = (DISPLAY_HEIGHT - away_logo_rgba.height) // 2
|
paste_y = (DISPLAY_HEIGHT - away_logo_rgba.height) // 2
|
||||||
|
|
||||||
# Manual pixel paste (robust alternative)
|
# Manual pixel paste (robust alternative)
|
||||||
|
try:
|
||||||
for x in range(away_logo_rgba.width):
|
for x in range(away_logo_rgba.width):
|
||||||
for y in range(away_logo_rgba.height):
|
for y in range(away_logo_rgba.height):
|
||||||
r, g, b, a = away_logo_rgba.getpixel((x, y))
|
r, g, b, a = away_logo_rgba.getpixel((x, y))
|
||||||
@@ -341,6 +347,8 @@ def create_scorebug_image(game_details):
|
|||||||
# Ensure target pixel is within image bounds
|
# Ensure target pixel is within image bounds
|
||||||
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
||||||
img.putpixel((target_x, target_y), (r, g, b))
|
img.putpixel((target_x, target_y), (r, g, b))
|
||||||
|
except AttributeError as ae:
|
||||||
|
logging.error(f"[NHL Debug] Away upcoming AttributeError accessing width/height in loop: {ae}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error loading/pasting away logo {game_details['away_logo_path']}: {e}")
|
logging.error(f"Error loading/pasting away logo {game_details['away_logo_path']}: {e}")
|
||||||
@@ -358,11 +366,17 @@ def create_scorebug_image(game_details):
|
|||||||
home_logo_rgba = Image.open(game_details["home_logo_path"]).convert("RGBA")
|
home_logo_rgba = Image.open(game_details["home_logo_path"]).convert("RGBA")
|
||||||
# Resize and reassign, instead of in-place thumbnail
|
# Resize and reassign, instead of in-place thumbnail
|
||||||
home_logo_rgba = home_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
home_logo_rgba = home_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
||||||
|
# --- Debugging ---
|
||||||
|
logging.debug(f"[NHL Debug] Home upcoming Type after resize: {type(home_logo_rgba)}")
|
||||||
|
logging.debug(f"[NHL Debug] Home upcoming Has width attr: {hasattr(home_logo_rgba, 'width')}")
|
||||||
|
logging.debug(f"[NHL Debug] Home upcoming Has height attr: {hasattr(home_logo_rgba, 'height')}")
|
||||||
|
# --- End Debugging ---
|
||||||
|
|
||||||
paste_x = home_logo_pos[0]
|
paste_x = home_logo_pos[0]
|
||||||
paste_y = (DISPLAY_HEIGHT - home_logo_rgba.height) // 2
|
paste_y = (DISPLAY_HEIGHT - home_logo_rgba.height) // 2
|
||||||
|
|
||||||
# Manual pixel paste (robust alternative)
|
# Manual pixel paste (robust alternative)
|
||||||
|
try:
|
||||||
for x in range(home_logo_rgba.width):
|
for x in range(home_logo_rgba.width):
|
||||||
for y in range(home_logo_rgba.height):
|
for y in range(home_logo_rgba.height):
|
||||||
r, g, b, a = home_logo_rgba.getpixel((x, y))
|
r, g, b, a = home_logo_rgba.getpixel((x, y))
|
||||||
@@ -372,6 +386,8 @@ def create_scorebug_image(game_details):
|
|||||||
# Ensure target pixel is within image bounds
|
# Ensure target pixel is within image bounds
|
||||||
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
||||||
img.putpixel((target_x, target_y), (r, g, b))
|
img.putpixel((target_x, target_y), (r, g, b))
|
||||||
|
except AttributeError as ae:
|
||||||
|
logging.error(f"[NHL Debug] Home upcoming AttributeError accessing width/height in loop: {ae}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error loading/pasting home logo {game_details['home_logo_path']}: {e}")
|
logging.error(f"Error loading/pasting home logo {game_details['home_logo_path']}: {e}")
|
||||||
@@ -1086,11 +1102,17 @@ class NHLScoreboardManager:
|
|||||||
away_logo_rgba = Image.open(game_details["away_logo_path"]).convert("RGBA")
|
away_logo_rgba = Image.open(game_details["away_logo_path"]).convert("RGBA")
|
||||||
# Resize and reassign, instead of in-place thumbnail
|
# Resize and reassign, instead of in-place thumbnail
|
||||||
away_logo_rgba = away_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
away_logo_rgba = away_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
||||||
|
# --- Debugging ---
|
||||||
|
logging.debug(f"[NHL Debug] Away upcoming Type after resize: {type(away_logo_rgba)}")
|
||||||
|
logging.debug(f"[NHL Debug] Away upcoming Has width attr: {hasattr(away_logo_rgba, 'width')}")
|
||||||
|
logging.debug(f"[NHL Debug] Away upcoming Has height attr: {hasattr(away_logo_rgba, 'height')}")
|
||||||
|
# --- End Debugging ---
|
||||||
|
|
||||||
paste_x = away_logo_x
|
paste_x = away_logo_x
|
||||||
paste_y = (self.display_height - away_logo_rgba.height) // 2
|
paste_y = (self.display_height - away_logo_rgba.height) // 2
|
||||||
|
|
||||||
# Manual pixel paste (robust alternative)
|
# Manual pixel paste (robust alternative)
|
||||||
|
try:
|
||||||
for x in range(away_logo_rgba.width):
|
for x in range(away_logo_rgba.width):
|
||||||
for y in range(away_logo_rgba.height):
|
for y in range(away_logo_rgba.height):
|
||||||
r, g, b, a = away_logo_rgba.getpixel((x, y))
|
r, g, b, a = away_logo_rgba.getpixel((x, y))
|
||||||
@@ -1100,6 +1122,8 @@ class NHLScoreboardManager:
|
|||||||
# Ensure target pixel is within image bounds
|
# Ensure target pixel is within image bounds
|
||||||
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
||||||
img.putpixel((target_x, target_y), (r, g, b))
|
img.putpixel((target_x, target_y), (r, g, b))
|
||||||
|
except AttributeError as ae:
|
||||||
|
logging.error(f"[NHL Debug] Away upcoming AttributeError accessing width/height in loop: {ae}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"[NHL] Error rendering upcoming away logo {game_details['away_logo_path']}: {e}")
|
logging.error(f"[NHL] Error rendering upcoming away logo {game_details['away_logo_path']}: {e}")
|
||||||
@@ -1113,11 +1137,17 @@ class NHLScoreboardManager:
|
|||||||
home_logo_rgba = Image.open(game_details["home_logo_path"]).convert("RGBA")
|
home_logo_rgba = Image.open(game_details["home_logo_path"]).convert("RGBA")
|
||||||
# Resize and reassign, instead of in-place thumbnail
|
# Resize and reassign, instead of in-place thumbnail
|
||||||
home_logo_rgba = home_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
home_logo_rgba = home_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
||||||
|
# --- Debugging ---
|
||||||
|
logging.debug(f"[NHL Debug] Home upcoming Type after resize: {type(home_logo_rgba)}")
|
||||||
|
logging.debug(f"[NHL Debug] Home upcoming Has width attr: {hasattr(home_logo_rgba, 'width')}")
|
||||||
|
logging.debug(f"[NHL Debug] Home upcoming Has height attr: {hasattr(home_logo_rgba, 'height')}")
|
||||||
|
# --- End Debugging ---
|
||||||
|
|
||||||
paste_x = home_logo_x
|
paste_x = home_logo_x
|
||||||
paste_y = (self.display_height - home_logo_rgba.height) // 2
|
paste_y = (self.display_height - home_logo_rgba.height) // 2
|
||||||
|
|
||||||
# Manual pixel paste (robust alternative)
|
# Manual pixel paste (robust alternative)
|
||||||
|
try:
|
||||||
for x in range(home_logo_rgba.width):
|
for x in range(home_logo_rgba.width):
|
||||||
for y in range(home_logo_rgba.height):
|
for y in range(home_logo_rgba.height):
|
||||||
r, g, b, a = home_logo_rgba.getpixel((x, y))
|
r, g, b, a = home_logo_rgba.getpixel((x, y))
|
||||||
@@ -1127,6 +1157,8 @@ class NHLScoreboardManager:
|
|||||||
# Ensure target pixel is within image bounds
|
# Ensure target pixel is within image bounds
|
||||||
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
||||||
img.putpixel((target_x, target_y), (r, g, b))
|
img.putpixel((target_x, target_y), (r, g, b))
|
||||||
|
except AttributeError as ae:
|
||||||
|
logging.error(f"[NHL Debug] Home upcoming AttributeError accessing width/height in loop: {ae}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"[NHL] Error rendering upcoming home logo {game_details['home_logo_path']}: {e}")
|
logging.error(f"[NHL] Error rendering upcoming home logo {game_details['home_logo_path']}: {e}")
|
||||||
@@ -1200,12 +1232,18 @@ class NHLScoreboardManager:
|
|||||||
away_logo_rgba = Image.open(game_details["away_logo_path"]).convert("RGBA")
|
away_logo_rgba = Image.open(game_details["away_logo_path"]).convert("RGBA")
|
||||||
# Resize and reassign, instead of in-place thumbnail
|
# Resize and reassign, instead of in-place thumbnail
|
||||||
away_logo_rgba = away_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
away_logo_rgba = away_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
||||||
|
# --- Debugging ---
|
||||||
|
logging.debug(f"[NHL Debug] Away scorebug Type after resize: {type(away_logo_rgba)}")
|
||||||
|
logging.debug(f"[NHL Debug] Away scorebug Has width attr: {hasattr(away_logo_rgba, 'width')}")
|
||||||
|
logging.debug(f"[NHL Debug] Away scorebug Has height attr: {hasattr(away_logo_rgba, 'height')}")
|
||||||
|
# --- End Debugging ---
|
||||||
away_logo_drawn_size = away_logo_rgba.size # Keep track of size
|
away_logo_drawn_size = away_logo_rgba.size # Keep track of size
|
||||||
|
|
||||||
paste_x = away_logo_x
|
paste_x = away_logo_x
|
||||||
paste_y = (self.display_height - away_logo_rgba.height) // 2
|
paste_y = (self.display_height - away_logo_rgba.height) // 2
|
||||||
|
|
||||||
# Manual pixel paste (robust alternative)
|
# Manual pixel paste (robust alternative)
|
||||||
|
try:
|
||||||
for x in range(away_logo_rgba.width):
|
for x in range(away_logo_rgba.width):
|
||||||
for y in range(away_logo_rgba.height):
|
for y in range(away_logo_rgba.height):
|
||||||
r, g, b, a = away_logo_rgba.getpixel((x, y))
|
r, g, b, a = away_logo_rgba.getpixel((x, y))
|
||||||
@@ -1215,6 +1253,8 @@ class NHLScoreboardManager:
|
|||||||
# Ensure target pixel is within image bounds
|
# Ensure target pixel is within image bounds
|
||||||
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
||||||
img.putpixel((target_x, target_y), (r, g, b))
|
img.putpixel((target_x, target_y), (r, g, b))
|
||||||
|
except AttributeError as ae:
|
||||||
|
logging.error(f"[NHL Debug] Away scorebug AttributeError accessing width/height in loop: {ae}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"[NHL] Error rendering away logo {game_details['away_logo_path']}: {e}")
|
logging.error(f"[NHL] Error rendering away logo {game_details['away_logo_path']}: {e}")
|
||||||
@@ -1232,12 +1272,18 @@ class NHLScoreboardManager:
|
|||||||
home_logo_rgba = Image.open(game_details["home_logo_path"]).convert("RGBA")
|
home_logo_rgba = Image.open(game_details["home_logo_path"]).convert("RGBA")
|
||||||
# Resize and reassign, instead of in-place thumbnail
|
# Resize and reassign, instead of in-place thumbnail
|
||||||
home_logo_rgba = home_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
home_logo_rgba = home_logo_rgba.resize(logo_size, Image.Resampling.LANCZOS)
|
||||||
|
# --- Debugging ---
|
||||||
|
logging.debug(f"[NHL Debug] Home scorebug Type after resize: {type(home_logo_rgba)}")
|
||||||
|
logging.debug(f"[NHL Debug] Home scorebug Has width attr: {hasattr(home_logo_rgba, 'width')}")
|
||||||
|
logging.debug(f"[NHL Debug] Home scorebug Has height attr: {hasattr(home_logo_rgba, 'height')}")
|
||||||
|
# --- End Debugging ---
|
||||||
home_logo_drawn_size = home_logo_rgba.size # Keep track of size
|
home_logo_drawn_size = home_logo_rgba.size # Keep track of size
|
||||||
|
|
||||||
paste_x = home_logo_x
|
paste_x = home_logo_x
|
||||||
paste_y = (self.display_height - home_logo_rgba.height) // 2
|
paste_y = (self.display_height - home_logo_rgba.height) // 2
|
||||||
|
|
||||||
# Manual pixel paste (robust alternative)
|
# Manual pixel paste (robust alternative)
|
||||||
|
try:
|
||||||
for x in range(home_logo_rgba.width):
|
for x in range(home_logo_rgba.width):
|
||||||
for y in range(home_logo_rgba.height):
|
for y in range(home_logo_rgba.height):
|
||||||
r, g, b, a = home_logo_rgba.getpixel((x, y))
|
r, g, b, a = home_logo_rgba.getpixel((x, y))
|
||||||
@@ -1247,6 +1293,8 @@ class NHLScoreboardManager:
|
|||||||
# Ensure target pixel is within image bounds
|
# Ensure target pixel is within image bounds
|
||||||
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
if 0 <= target_x < img.width and 0 <= target_y < img.height:
|
||||||
img.putpixel((target_x, target_y), (r, g, b))
|
img.putpixel((target_x, target_y), (r, g, b))
|
||||||
|
except AttributeError as ae:
|
||||||
|
logging.error(f"[NHL Debug] Home scorebug AttributeError accessing width/height in loop: {ae}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"[NHL] Error rendering home logo {game_details['home_logo_path']}: {e}")
|
logging.error(f"[NHL] Error rendering home logo {game_details['home_logo_path']}: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user