diff --git a/.gitignore b/.gitignore index 753dc64..1161826 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env +preferred_sessions.json log/ !log/.gitkeep @@ -177,4 +178,4 @@ poetry.toml # LSP config files pyrightconfig.json -# End of https://www.toptal.com/developers/gitignore/api/python \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/python diff --git a/preferred_sessions.json.example b/preferred_sessions.json.example new file mode 100644 index 0000000..39c36ad --- /dev/null +++ b/preferred_sessions.json.example @@ -0,0 +1,22 @@ +[ + { + "day_of_week": 0, + "start_time": "17:45", + "session_name_contains": "WEIGHTLIFTING LOUVRE 3" + }, + { + "day_of_week": 4, + "start_time": "17:00", + "session_name_contains": "CONDITIONING LOUVRE 3" + }, + { + "day_of_week": 5, + "start_time": "12:30", + "session_name_contains": "HYROX" + }, + { + "day_of_week": 5, + "start_time": "12:30", + "session_name_contains": "CONDITIONING" + } +] diff --git a/src/session_config.py b/src/session_config.py index 0cd9340..ffc24da 100644 --- a/src/session_config.py +++ b/src/session_config.py @@ -36,20 +36,19 @@ class SessionConfig: preferred_sessions.append((day_of_week, start_time, session_name_contains)) except FileNotFoundError: - # Log a warning if the file is not found - logging.warning(f"Configuration file '{config_file}' not found. Falling back to default settings.") + # Log error and exit if the file is not found + logging.error(f"Configuration file '{config_file}' not found. Please create the configuration file.") + logging.error("You can copy 'preferred_sessions.json.example' to 'preferred_sessions.json' as a template.") + raise SystemExit(1) except json.JSONDecodeError: - # Log a warning if the file is not a valid JSON - logging.warning(f"Failed to decode JSON from file '{config_file}'. Falling back to default settings.") + # Log error and exit if the file is not a valid JSON + logging.error(f"Failed to decode JSON from file '{config_file}'. Please check the file format.") + raise SystemExit(1) - # Fallback to default hardcoded sessions if no valid sessions were loaded + # Return empty list if no valid sessions were loaded if not preferred_sessions: - preferred_sessions = [ - (2, "18:30", "CONDITIONING"), # Wednesday 18:30 CONDITIONING - (4, "17:00", "WEIGHTLIFTING"), # Friday 17:00 WEIGHTLIFTING - (5, "12:30", "HYROX"), # Saturday 12:30 HYROX - ] + return [] return preferred_sessions