From 74788a2ccb6bade0d22ad5b235f924a3488f58fa Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 1 Apr 2013 20:14:20 +0200 Subject: [PATCH 1/2] Remove the BACKENDS setting --- docs/development.rst | 8 +------- mopidy/settings.py | 19 ------------------- mopidy/utils/settings.py | 2 -- tests/backends/local/playback_test.py | 1 - tests/backends/local/tracklist_test.py | 1 - tests/utils/settings_test.py | 7 ------- 6 files changed, 1 insertion(+), 37 deletions(-) diff --git a/docs/development.rst b/docs/development.rst index 4374acf2..776b004d 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -281,12 +281,6 @@ settings file in the following way:: import os profile = os.environ.get('PROFILE', '').split(',') - if 'spotify' in profile: - BACKENDS = (u'mopidy.backends.spotify.SpotifyBackend',) - elif 'local' in profile: - BACKENDS = (u'mopidy.backends.local.LocalBackend',) - LOCAL_MUSIC_PATH = u'~/music' - if 'shoutcast' in profile: OUTPUT = u'lame ! shout2send mount="/stream"' elif 'silent' in profile: @@ -296,7 +290,7 @@ settings file in the following way:: SPOTIFY_USERNAME = u'xxxxx' SPOTIFY_PASSWORD = u'xxxxx' -Using this setup you can now run Mopidy with ``PROFILE=silent,spotify mopidy`` +Using this setup you can now run Mopidy with ``PROFILE=silent mopidy`` if you for instance want to test Spotify without any actual audio output. diff --git a/mopidy/settings.py b/mopidy/settings.py index d0d279c2..7df43ae5 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -9,25 +9,6 @@ All available settings and their default values. from __future__ import unicode_literals -#: List of playback backends to use. See :ref:`backend-implementations` for all -#: available backends. -#: -#: When results from multiple backends are combined, they are combined in the -#: order the backends are listed here. -#: -#: Default:: -#: -#: BACKENDS = ( -#: u'mopidy.backends.local.LocalBackend', -#: u'mopidy.backends.spotify.SpotifyBackend', -#: u'mopidy.backends.stream.StreamBackend', -#: ) -BACKENDS = ( - 'mopidy.backends.local.LocalBackend', - 'mopidy.backends.spotify.SpotifyBackend', - 'mopidy.backends.stream.StreamBackend', -) - #: The log format used for informational logging. #: #: See http://docs.python.org/2/library/logging.html#formatter-objects for diff --git a/mopidy/utils/settings.py b/mopidy/utils/settings.py index 8ae61e5b..011b723a 100644 --- a/mopidy/utils/settings.py +++ b/mopidy/utils/settings.py @@ -143,13 +143,11 @@ def validate_settings(defaults, settings): } must_be_iterable = [ - 'BACKENDS', 'FRONTENDS', 'STREAM_PROTOCOLS', ] must_have_value_set = [ - 'BACKENDS', 'FRONTENDS', ] diff --git a/tests/backends/local/playback_test.py b/tests/backends/local/playback_test.py index 834ce8e0..8d997d2e 100644 --- a/tests/backends/local/playback_test.py +++ b/tests/backends/local/playback_test.py @@ -17,7 +17,6 @@ class LocalPlaybackControllerTest(PlaybackControllerTest, unittest.TestCase): Track(uri=generate_song(i), length=4464) for i in range(1, 4)] def setUp(self): - settings.BACKENDS = ('mopidy.backends.local.LocalBackend',) settings.LOCAL_TAG_CACHE_FILE = path_to_data_dir('empty_tag_cache') super(LocalPlaybackControllerTest, self).setUp() diff --git a/tests/backends/local/tracklist_test.py b/tests/backends/local/tracklist_test.py index ec09ac83..0c47a5db 100644 --- a/tests/backends/local/tracklist_test.py +++ b/tests/backends/local/tracklist_test.py @@ -15,7 +15,6 @@ class LocalTracklistControllerTest(TracklistControllerTest, unittest.TestCase): Track(uri=generate_song(i), length=4464) for i in range(1, 4)] def setUp(self): - settings.BACKENDS = ('mopidy.backends.local.LocalBackend',) settings.LOCAL_TAG_CACHE_FILE = path_to_data_dir('empty_tag_cache') super(LocalTracklistControllerTest, self).setUp() diff --git a/tests/utils/settings_test.py b/tests/utils/settings_test.py index 51f0d89c..4e7d9d77 100644 --- a/tests/utils/settings_test.py +++ b/tests/utils/settings_test.py @@ -11,7 +11,6 @@ from tests import unittest class ValidateSettingsTest(unittest.TestCase): def setUp(self): self.defaults = { - 'BACKENDS': ['a'], 'FRONTENDS': ['a'], 'MPD_SERVER_HOSTNAME': '::', 'MPD_SERVER_PORT': 6600, @@ -81,12 +80,6 @@ class ValidateSettingsTest(unittest.TestCase): self.assertEqual( result['FRONTENDS'], 'Must be set.') - def test_empty_backends_list_returns_error(self): - result = setting_utils.validate_settings( - self.defaults, {'BACKENDS': []}) - self.assertEqual( - result['BACKENDS'], 'Must be set.') - def test_noniterable_multivalue_setting_returns_error(self): result = setting_utils.validate_settings( self.defaults, {'FRONTENDS': ('this is not a tuple')}) From aa1f8199c2adc0cbdc912e70792a01e39f909712 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 1 Apr 2013 20:22:29 +0200 Subject: [PATCH 2/2] Remove the FRONTENDS setting --- docs/api/frontends.rst | 4 ++-- docs/clients/mpris.rst | 11 +++++------ docs/extensiondev.rst | 2 ++ mopidy/frontends/http/__init__.py | 17 +++++++++-------- mopidy/frontends/lastfm/__init__.py | 4 +--- mopidy/frontends/mpd/__init__.py | 4 +--- mopidy/frontends/mpris/__init__.py | 4 +--- mopidy/settings.py | 16 ---------------- mopidy/utils/settings.py | 9 --------- tests/utils/settings_test.py | 15 --------------- 10 files changed, 21 insertions(+), 65 deletions(-) diff --git a/docs/api/frontends.rst b/docs/api/frontends.rst index 8488b408..a6e6f500 100644 --- a/docs/api/frontends.rst +++ b/docs/api/frontends.rst @@ -20,8 +20,8 @@ The following requirements applies to any frontend implementation: - It MAY use additional actors to implement whatever it does, and using actors in frontend implementations is encouraged. -- The frontend is activated by including its main actor in the - :attr:`mopidy.settings.FRONTENDS` setting. +- The frontend is enabled if the extension it is part of is enabled. See + :ref:`extensiondev` for more information. - The main actor MUST be able to start and stop the frontend when the main actor is started and stopped. diff --git a/docs/clients/mpris.rst b/docs/clients/mpris.rst index c782fa26..28da63ed 100644 --- a/docs/clients/mpris.rst +++ b/docs/clients/mpris.rst @@ -36,12 +36,11 @@ Mopidy executable. If this isn't in place, the sound menu will not detect that Mopidy is running. Next, Mopidy's MPRIS frontend must be running for the sound menu to be able to -control Mopidy. The frontend is activated by default, so unless you've changed -the :attr:`mopidy.settings.FRONTENDS` setting, you should be good to go. Keep -an eye out for warnings or errors from the MPRIS frontend when you start -Mopidy, since it may fail because of missing dependencies or because Mopidy is -started outside of X; the frontend won't work if ``$DISPLAY`` isn't set when -Mopidy is started. +control Mopidy. The frontend is enabled by default, so as long as you have all +its dependencies available, you should be good to go. Keep an eye out for +warnings or errors from the MPRIS frontend when you start Mopidy, since it may +fail because of missing dependencies or because Mopidy is started outside of X; +the frontend won't work if ``$DISPLAY`` isn't set when Mopidy is started. Under normal use, if Mopidy isn't running and you open the menu and click on "Mopidy Music Server", a terminal window will open and automatically start diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index 04c6aa6b..976f8f84 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -1,3 +1,5 @@ +.. _extensiondev: + ********************* Extension development ********************* diff --git a/mopidy/frontends/http/__init__.py b/mopidy/frontends/http/__init__.py index 0107e357..7b99efd0 100644 --- a/mopidy/frontends/http/__init__.py +++ b/mopidy/frontends/http/__init__.py @@ -25,8 +25,10 @@ from a web based client. Setup ===== -When this frontend is included in :attr:`mopidy.settings.FRONTENDS`, it starts -a web server at the port specified by :attr:`mopidy.settings.HTTP_SERVER_PORT`. +The frontend is enabled by default if all dependencies are available. + +When it is enabled it starts a web server at the port specified by +:attr:`mopidy.settings.HTTP_SERVER_PORT`. .. warning:: Security @@ -364,15 +366,14 @@ event listeners, and delete the object like this: Example to get started with --------------------------- -1. Create an empty directory for your web client. +1. Make sure that you've installed all dependencies required by the HTTP + frontend. -2. Change the setting :attr:`mopidy.settings.HTTP_SERVER_STATIC_DIR` to point +2. Create an empty directory for your web client. + +3. Change the setting :attr:`mopidy.settings.HTTP_SERVER_STATIC_DIR` to point to your new directory. -3. Make sure that you've included - ``mopidy.frontends.http.HttpFrontend`` in - :attr:`mopidy.settings.FRONTENDS`. - 4. Start/restart Mopidy. 5. Create a file in the directory named ``index.html`` containing e.g. "Hello, diff --git a/mopidy/frontends/lastfm/__init__.py b/mopidy/frontends/lastfm/__init__.py index df41d130..439ada50 100644 --- a/mopidy/frontends/lastfm/__init__.py +++ b/mopidy/frontends/lastfm/__init__.py @@ -24,9 +24,7 @@ Frontend which scrobbles the music you play to your `Last.fm **Usage:** -Make sure :attr:`mopidy.settings.FRONTENDS` includes -``mopidy.frontends.lastfm.LastfmFrontend``. By default, the setting includes -the Last.fm frontend. +The frontend is enabled by default if all dependencies are available. """ diff --git a/mopidy/frontends/mpd/__init__.py b/mopidy/frontends/mpd/__init__.py index 10334bcf..5cb8b8c0 100644 --- a/mopidy/frontends/mpd/__init__.py +++ b/mopidy/frontends/mpd/__init__.py @@ -22,9 +22,7 @@ original MPD server. **Usage:** -Make sure :attr:`mopidy.settings.FRONTENDS` includes -``mopidy.frontends.mpd.MpdFrontend``. By default, the setting includes the MPD -frontend. +The frontend is enabled by default. **Limitations:** diff --git a/mopidy/frontends/mpris/__init__.py b/mopidy/frontends/mpris/__init__.py index 268a9bc2..940c4210 100644 --- a/mopidy/frontends/mpris/__init__.py +++ b/mopidy/frontends/mpris/__init__.py @@ -32,9 +32,7 @@ An example of an MPRIS client is the `Ubuntu Sound Menu **Usage:** -Make sure :attr:`mopidy.settings.FRONTENDS` includes -``mopidy.frontends.mpris.MprisFrontend``. By default, the setting includes the -MPRIS frontend. +The frontend is enabled by default if all dependencies are available. **Testing the frontend** diff --git a/mopidy/settings.py b/mopidy/settings.py index 7df43ae5..cde6430a 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -39,22 +39,6 @@ DEBUG_LOG_FILENAME = 'mopidy.log' #: DESKTOP_FILE = u'/usr/share/applications/mopidy.desktop' DESKTOP_FILE = '/usr/share/applications/mopidy.desktop' -#: List of server frontends to use. See :ref:`frontend-implementations` for -#: available frontends. -#: -#: Default:: -#: -#: FRONTENDS = ( -#: u'mopidy.frontends.mpd.MpdFrontend', -#: u'mopidy.frontends.lastfm.LastfmFrontend', -#: u'mopidy.frontends.mpris.MprisFrontend', -#: ) -FRONTENDS = ( - 'mopidy.frontends.mpd.MpdFrontend', - 'mopidy.frontends.lastfm.LastfmFrontend', - 'mopidy.frontends.mpris.MprisFrontend', -) - #: Which address Mopidy's HTTP server should bind to. #: #: Used by :mod:`mopidy.frontends.http`. diff --git a/mopidy/utils/settings.py b/mopidy/utils/settings.py index 011b723a..051f0f1c 100644 --- a/mopidy/utils/settings.py +++ b/mopidy/utils/settings.py @@ -123,7 +123,6 @@ def validate_settings(defaults, settings): changed = { 'DUMP_LOG_FILENAME': 'DEBUG_LOG_FILENAME', 'DUMP_LOG_FORMAT': 'DEBUG_LOG_FORMAT', - 'FRONTEND': 'FRONTENDS', 'GSTREAMER_AUDIO_SINK': 'OUTPUT', 'LOCAL_MUSIC_FOLDER': 'LOCAL_MUSIC_PATH', 'LOCAL_OUTPUT_OVERRIDE': 'OUTPUT', @@ -143,14 +142,9 @@ def validate_settings(defaults, settings): } must_be_iterable = [ - 'FRONTENDS', 'STREAM_PROTOCOLS', ] - must_have_value_set = [ - 'FRONTENDS', - ] - for setting, value in settings.iteritems(): if setting in changed: if changed[setting] is None: @@ -180,9 +174,6 @@ def validate_settings(defaults, settings): 'Must be a tuple. ' "Remember the comma after single values: (u'value',)") - elif setting in must_have_value_set and not value: - errors[setting] = 'Must be set.' - elif setting not in defaults and not setting.startswith('CUSTOM_'): errors[setting] = 'Unknown setting.' suggestion = did_you_mean(setting, defaults) diff --git a/tests/utils/settings_test.py b/tests/utils/settings_test.py index 4e7d9d77..2c13066c 100644 --- a/tests/utils/settings_test.py +++ b/tests/utils/settings_test.py @@ -11,7 +11,6 @@ from tests import unittest class ValidateSettingsTest(unittest.TestCase): def setUp(self): self.defaults = { - 'FRONTENDS': ['a'], 'MPD_SERVER_HOSTNAME': '::', 'MPD_SERVER_PORT': 6600, 'SPOTIFY_BITRATE': 160, @@ -74,20 +73,6 @@ class ValidateSettingsTest(unittest.TestCase): 'SPOTIFY_USERNAME', None) self.assertEqual(None, not_secret) - def test_empty_frontends_list_returns_error(self): - result = setting_utils.validate_settings( - self.defaults, {'FRONTENDS': []}) - self.assertEqual( - result['FRONTENDS'], 'Must be set.') - - def test_noniterable_multivalue_setting_returns_error(self): - result = setting_utils.validate_settings( - self.defaults, {'FRONTENDS': ('this is not a tuple')}) - self.assertEqual( - result['FRONTENDS'], - 'Must be a tuple. ' - "Remember the comma after single values: (u'value',)") - class SettingsProxyTest(unittest.TestCase): def setUp(self):