From c1c77032461cf0c7d000b10d0abcbf4ae31d649c Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Sat, 21 Mar 2020 13:53:50 +0100 Subject: [PATCH] Renamed simpleutil to util. --- libraries/database/broadcasts.py | 2 +- modules/base/{simpleutil.py => utils.py} | 0 modules/communication/liquidsoap/client.py | 2 +- modules/scheduling/calender_fetcher.py | 2 +- modules/scheduling/fallback_manager.py | 37 +++++++++++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) rename modules/base/{simpleutil.py => utils.py} (100%) diff --git a/libraries/database/broadcasts.py b/libraries/database/broadcasts.py index 605b54ab..b1108309 100644 --- a/libraries/database/broadcasts.py +++ b/libraries/database/broadcasts.py @@ -40,7 +40,7 @@ from sqlalchemy import create_engine from modules.base.enum import Channel, ChannelType from modules.base.config import AuraConfig -from modules.base.simpleutil import SimpleUtil, EngineUtil +from modules.base.utils import SimpleUtil, EngineUtil # Init Config diff --git a/modules/base/simpleutil.py b/modules/base/utils.py similarity index 100% rename from modules/base/simpleutil.py rename to modules/base/utils.py diff --git a/modules/communication/liquidsoap/client.py b/modules/communication/liquidsoap/client.py index 3595de0f..76151f9a 100644 --- a/modules/communication/liquidsoap/client.py +++ b/modules/communication/liquidsoap/client.py @@ -30,7 +30,7 @@ import logging from multiprocessing import Lock from modules.base.exceptions import LQConnectionError -from modules.base.simpleutil import TerminalColors +from modules.base.utils import TerminalColors """ LiquidSoapClient Class diff --git a/modules/scheduling/calender_fetcher.py b/modules/scheduling/calender_fetcher.py index 7bd3e3c7..814f8a03 100644 --- a/modules/scheduling/calender_fetcher.py +++ b/modules/scheduling/calender_fetcher.py @@ -6,7 +6,7 @@ import simplejson from datetime import datetime, timedelta #from modules.models.schedule import Schedule -from modules.base.simpleutil import SimpleUtil +from modules.base.utils import SimpleUtil class CalendarFetcher: diff --git a/modules/scheduling/fallback_manager.py b/modules/scheduling/fallback_manager.py index 83fd5ffd..5000e148 100644 --- a/modules/scheduling/fallback_manager.py +++ b/modules/scheduling/fallback_manager.py @@ -36,7 +36,8 @@ import random import librosa from accessify import private, protected -from modules.base.simpleutil import SimpleUtil +from modules.base.enum import FallbackType +from modules.base.utils import SimpleUtil from modules.communication.mail import AuraMailer @@ -83,6 +84,40 @@ class FallbackManager: # + def get_fallback(self, schedule, type): + """ + Checks if the given schedule is valid and returns a valid fallback + if required. + """ + type = None + playlist_id = schedule.playlist_id + + if not schedule.playlist_id: + if not schedule.show_fallback_id: + if not schedule.schedule_fallback_id: + if not schedule.station_fallback_id: + raise Exception + else: + type = FallbackType.STATION + playlist_id = schedule.station_fallback_id + else: + type = FallbackType.TIMESLOT + playlist_id = schedule.schedule_fallback_id + else: + type = FallbackType.SHOW + playlist_id = schedule.show_fallback_id + + if type: + self.logger.warn("Detected fallback type '%s' required for schedule %s" % (type, str(schedule))) + + + return (type, playlist_id) + + + def validate_playlist(self, playlist_id): + pass + + def get_fallback_for(self, fallbackname): """ Retrieves a random fallback audio source for any of the types: -- GitLab