Commit 2569d5d9 authored by David Trattnig's avatar David Trattnig
Browse files

Fail gracefully if there's no schedule. #3

parent 2f06dcbe
......@@ -90,7 +90,6 @@ class FallbackManager:
Args:
schedule (Schedule): The schedule to resolve the playlist for
Returns:
(Playlist): The resolved playlist
......@@ -103,7 +102,8 @@ class FallbackManager:
if not self.validate_playlist(schedule, "schedule_fallback"):
if not self.validate_playlist(schedule, "show_fallback"):
if not self.validate_playlist(schedule, "station_fallback"):
raise Exception("No (fallback) playlists for schedule #%s available - not even a single one!" % schedule.schedule_id)
self.logger.error(SimpleUtil.red("No (fallback) playlists for schedule #%s available - not even a single one!" % schedule.schedule_id))
return None
else:
type = PlaylistType.STATION
playlist = schedule.station_fallback
......
......@@ -475,19 +475,19 @@ class AuraScheduler(threading.Thread):
if active_schedule.playlist:
planned_playlist = active_schedule.playlist[0] # FIXME Improve model without list
resolved_playlist = self.fallback_manager.resolve_playlist(active_schedule)
type = str(EngineUtil.get_playlist_type(resolved_playlist.fallback_type))
s += "\n│ Playing schedule %s " % active_schedule
if planned_playlist:
if resolved_playlist and resolved_playlist.playlist_id != planned_playlist.playlist_id:
s += "\n│ └── Playlist %s " % planned_playlist
s += "\n│ "
s += SimpleUtil.red("↑↑↑ That's the originally planned playlist.") + ("Instead playing the `%s` playlist below ↓↓↓" % SimpleUtil.cyan(type))
s += SimpleUtil.red("↑↑↑ That's the originally planned playlist.") + ("Instead playing the fallback playlist below ↓↓↓")
if resolved_playlist:
if resolved_playlist:
if not planned_playlist:
fallback_type = str(EngineUtil.get_playlist_type(resolved_playlist.fallback_type))
s += "\n│ "
s += SimpleUtil.red("No Playlist assigned to schedule. Instead playing the `%s` playlist below ↓↓↓" % SimpleUtil.cyan(type))
s += SimpleUtil.red("No Playlist assigned to schedule. Instead playing the `%s` playlist below ↓↓↓" % SimpleUtil.cyan(fallback_type))
s += "\n│ └── Playlist %s " % resolved_playlist
......@@ -525,15 +525,16 @@ class AuraScheduler(threading.Thread):
else:
for schedule in next_schedules:
resolved_playlist = self.fallback_manager.resolve_playlist(schedule)
type = str(EngineUtil.get_playlist_type(resolved_playlist.fallback_type))
s += "\n│ Queued schedule %s " % schedule
s += "\n│ └── Playlist %s (Type: %s)" % (resolved_playlist, SimpleUtil.cyan(type))
if resolved_playlist.end_unix > schedule.end_unix:
s += "\n│ %s! " % \
(SimpleUtil.red("↑↑↑ Playlist #%s ends after Schedule #%s!" % (resolved_playlist.playlist_id, schedule.schedule_id)))
entries = self.preprocess_entries(resolved_playlist.entries, False)
s += self.build_playlist_string(entries)
if resolved_playlist:
fallback_type = str(EngineUtil.get_playlist_type(resolved_playlist.fallback_type))
s += "\n│ Queued schedule %s " % schedule
s += "\n│ └── Playlist %s (Type: %s)" % (resolved_playlist, SimpleUtil.cyan(fallback_type))
if resolved_playlist.end_unix > schedule.end_unix:
s += "\n│ %s! " % \
(SimpleUtil.red("↑↑↑ Playlist #%s ends after Schedule #%s!" % (resolved_playlist.playlist_id, schedule.schedule_id)))
entries = self.preprocess_entries(resolved_playlist.entries, False)
s += self.build_playlist_string(entries)
s += "\n└──────────────────────────────────────────────────────────────────────────────────────────────────────\n\n"
return s
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment