From d0f87859361464872ea88841bd59a97989671f7e Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:06:07 -0400 Subject: [PATCH] troubleshooting of the day manager --- src/of_the_day_manager.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/of_the_day_manager.py b/src/of_the_day_manager.py index ef5641a2..cd542886 100644 --- a/src/of_the_day_manager.py +++ b/src/of_the_day_manager.py @@ -169,19 +169,27 @@ class OfTheDayManager: # If data_file already contains 'of_the_day/', use it as is if data_file.startswith('of_the_day/'): possible_paths.extend([ + os.path.join(current_dir, data_file), # Current working directory first os.path.join(script_dir, '..', data_file), - os.path.join(current_dir, data_file), - os.path.join('/home/ledpi/LEDMatrix', data_file), # Explicit Pi path data_file ]) else: possible_paths.extend([ + os.path.join(current_dir, 'of_the_day', data_file), # Current working directory first os.path.join(script_dir, '..', 'of_the_day', data_file), - os.path.join(current_dir, 'of_the_day', data_file), - os.path.join('/home/ledpi/LEDMatrix/of_the_day', data_file), # Explicit Pi path os.path.join('of_the_day', data_file) ]) + # Remove duplicates while preserving order + seen = set() + unique_paths = [] + for path in possible_paths: + abs_path = os.path.abspath(path) + if abs_path not in seen: + seen.add(abs_path) + unique_paths.append(abs_path) + possible_paths = unique_paths + file_path = None for potential_path in possible_paths: abs_path = os.path.abspath(potential_path) @@ -190,6 +198,13 @@ class OfTheDayManager: logger.debug(f"Found data file for {category_name} at: {file_path}") break + # Final fallback - try the direct path relative to current working directory + if file_path is None: + direct_path = os.path.join(current_dir, 'of_the_day', os.path.basename(data_file)) + if os.path.exists(direct_path): + file_path = direct_path + logger.debug(f"Found data file for {category_name} using direct fallback: {file_path}") + if file_path is None: # Use the first attempted path for error reporting file_path = os.path.abspath(possible_paths[0])