Make Spotify backend fail early if settings is incomplete

This commit is contained in:
Stein Magnus Jodal 2011-06-10 13:46:50 +02:00
parent 05c533014e
commit d46c22dca3

View File

@ -72,19 +72,22 @@ class SpotifyBackend(ThreadingActor, Backend):
self.gstreamer = None
self.spotify = None
# Fail early if settings are not present
self.username = settings.SPOTIFY_USERNAME
self.password = settings.SPOTIFY_PASSWORD
def on_start(self):
gstreamer_refs = ActorRegistry.get_by_class(GStreamer)
assert len(gstreamer_refs) == 1, 'Expected exactly one running gstreamer.'
self.gstreamer = gstreamer_refs[0].proxy()
logger.info(u'Mopidy uses SPOTIFY(R) CORE')
self.spotify = self._connect()
def _connect(self):
from .session_manager import SpotifySessionManager
logger.info(u'Mopidy uses SPOTIFY(R) CORE')
logger.debug(u'Connecting to Spotify')
spotify = SpotifySessionManager(
settings.SPOTIFY_USERNAME, settings.SPOTIFY_PASSWORD)
spotify = SpotifySessionManager(self.username, self.password)
spotify.start()
return spotify