Compare commits
2 Commits
795016a60c
...
d1e5fc1003
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1e5fc1003 | ||
|
|
7d03f5b40c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
.env
|
||||
preferred_sessions.json
|
||||
log/
|
||||
!log/.gitkeep
|
||||
|
||||
|
||||
22
preferred_sessions.json.example
Normal file
22
preferred_sessions.json.example
Normal file
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user