diff --git a/mopidy/backends/spotify/__init__.py b/mopidy/backends/spotify/__init__.py index d85e91b2..021277f2 100644 --- a/mopidy/backends/spotify/__init__.py +++ b/mopidy/backends/spotify/__init__.py @@ -61,7 +61,9 @@ class SpotifyBackend(ThreadingActor, Backend): self.uri_handlers = [u'spotify:', u'http://open.spotify.com/'] - # TODO-PYKKA: Do setup after actor starts? + self.spotify = None + + def post_start(self): self.spotify = self._connect() def _connect(self): diff --git a/mopidy/frontends/lastfm.py b/mopidy/frontends/lastfm.py index f8a46c0f..4a703c22 100644 --- a/mopidy/frontends/lastfm.py +++ b/mopidy/frontends/lastfm.py @@ -41,10 +41,7 @@ class LastfmFrontend(ThreadingActor, BaseFrontend): self.lastfm = None self.last_start_time = None - # TODO-PYKKA: Do setup after actor starts - self._setup() - - def _setup(self): + def post_start(self): try: username = settings.LASTFM_USERNAME password_hash = pylast.md5(settings.LASTFM_PASSWORD) diff --git a/mopidy/frontends/mpd/__init__.py b/mopidy/frontends/mpd/__init__.py index 3a1211ae..96500d9b 100644 --- a/mopidy/frontends/mpd/__init__.py +++ b/mopidy/frontends/mpd/__init__.py @@ -21,14 +21,12 @@ class MpdFrontend(ThreadingActor, BaseFrontend): """ def __init__(self): - # TODO-PYKKA: Do setup after actor starts? + self._thread = None + + def post_start(self): self._thread = MpdThread() self._thread.start() - def destroy(self): - """Destroys the MPD server.""" - self._thread.destroy() - class MpdThread(BaseThread): def __init__(self): diff --git a/mopidy/mixers/denon.py b/mopidy/mixers/denon.py index 36f0f3bd..832e7d1a 100644 --- a/mopidy/mixers/denon.py +++ b/mopidy/mixers/denon.py @@ -25,21 +25,16 @@ class DenonMixer(ThreadingActor, BaseMixer): - :attr:`mopidy.settings.MIXER_EXT_PORT` -- Example: ``/dev/ttyUSB0`` """ - def __init__(self): - """ - Connects using the serial specifications from Denon's RS-232 Protocol - specification: 9600bps 8N1. - """ - # TODO-PYKKA: Do setup after actor starts? - device = kwargs.get('device', None) - if device: - self._device = device - else: - from serial import Serial - self._device = Serial(port=settings.MIXER_EXT_PORT, timeout=0.2) + def __init__(self, *args, **kwargs): + self._device = kwargs.get('device', None) self._levels = ['99'] + ["%(#)02d" % {'#': v} for v in range(0, 99)] self._volume = 0 + def post_start(self): + if self._device is None: + from serial import Serial + self._device = Serial(port=settings.MIXER_EXT_PORT, timeout=0.2) + def _get_volume(self): self._ensure_open_device() self._device.write('MV?\r') diff --git a/mopidy/mixers/nad.py b/mopidy/mixers/nad.py index 2844f579..e12b8b92 100644 --- a/mopidy/mixers/nad.py +++ b/mopidy/mixers/nad.py @@ -75,10 +75,7 @@ class NadTalker(ThreadingActor): def __init__(self): self._device = None - # TODO-PYKKA: Do after actor starts? - self._setup() - - def _setup(self): + def post_start(self): self._open_connection() self._set_device_to_known_state() diff --git a/mopidy/outputs/gstreamer.py b/mopidy/outputs/gstreamer.py index b0b98d99..2a3d9adc 100644 --- a/mopidy/outputs/gstreamer.py +++ b/mopidy/outputs/gstreamer.py @@ -24,7 +24,7 @@ class GStreamerOutput(ThreadingActor, BaseOutput): def __init__(self): self.gst_pipeline = None - # TODO-PYKKA: Run setup after actor starts? + def post_start(self): self._setup_gstreamer() def _setup_gstreamer(self):