From c798257f00a61ecb73b1c904e35240d25f2510a0 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 5 Aug 2014 18:34:08 +0200 Subject: [PATCH 01/24] mpd: Test that "list album foo" responds correctly Previously, test_list_album_with_artist_name would only test that the command didn't fail. Now it also checks that the response is correct. That is, that the response contains albums. This makes the test detect the error reported in #817. (cherry picked from commit 9771eda23068f4581a30059ac597f1360d349dcd) --- tests/mpd/protocol/test_music_db.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mpd/protocol/test_music_db.py b/tests/mpd/protocol/test_music_db.py index 55ab75c5..e6712fef 100644 --- a/tests/mpd/protocol/test_music_db.py +++ b/tests/mpd/protocol/test_music_db.py @@ -880,7 +880,11 @@ class MusicDatabaseListTest(protocol.BaseTestCase): self.assertInResponse('OK') def test_list_album_with_artist_name(self): + self.backend.library.dummy_find_exact_result = SearchResult( + tracks=[Track(album=Album(name='foo'))]) + self.sendRequest('list "album" "anartist"') + self.assertInResponse('Album: foo') self.assertInResponse('OK') def test_list_album_with_artist_name_without_filter_value(self): From 210e1705e74cd571e7cf396785ae8cebf24c1957 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 5 Aug 2014 18:46:16 +0200 Subject: [PATCH 02/24] mpd: Fix list commands with 3 arguments (fixes #817) List commands with 3 arguments should return albums, not artists. (cherry picked from commit ec413126f1670ccf4f5853e6ee375239cdb374e6) --- mopidy/mpd/protocol/music_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy/mpd/protocol/music_db.py b/mopidy/mpd/protocol/music_db.py index acddf1f4..a5757915 100644 --- a/mopidy/mpd/protocol/music_db.py +++ b/mopidy/mpd/protocol/music_db.py @@ -257,7 +257,7 @@ def list_(context, *args): if len(parameters) == 1: if field != 'album': raise exceptions.MpdArgError('should be "Album" for 3 arguments') - return _list_artist(context, {'artist': parameters}) + return _list_album(context, {'artist': parameters}) try: query = _query_from_mpd_search_parameters(parameters, _LIST_MAPPING) From 73982f0455f2c0d93fe860122f0230fc87cbbb9c Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 5 Aug 2014 19:44:50 +0200 Subject: [PATCH 03/24] docs: Add the mpd list command fix to the changelog (cherry picked from commit 92fa75325d968bb271b8601447080c29bccbde5f) Conflicts: docs/changelog.rst --- docs/changelog.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 25655c98..8938b849 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,16 @@ Changelog This changelog is used to track all major changes to Mopidy. +v0.19.4 (UNRELEASED) +==================== + +Bug fix release. + + - MPD frontend: Make the ``list`` command return albums when sending 3 + arguments. This was incorrectly returning artists after the MPD command + changes in 0.19.0. (Fixes: :issue:`817`) + + v0.19.3 (2014-08-03) ==================== From 19f96f7944f2f19a7b5c7b1eeaaf8c24d52d06e4 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 5 Aug 2014 19:50:06 +0200 Subject: [PATCH 04/24] docs: Fix formatting (cherry picked from commit 26cfd24e113801b23a00bfb5d6706ee66e643e5b) --- docs/changelog.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8938b849..c0d48ec4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,9 +10,9 @@ v0.19.4 (UNRELEASED) Bug fix release. - - MPD frontend: Make the ``list`` command return albums when sending 3 - arguments. This was incorrectly returning artists after the MPD command - changes in 0.19.0. (Fixes: :issue:`817`) +- MPD frontend: Make the ``list`` command return albums when sending 3 + arguments. This was incorrectly returning artists after the MPD command + changes in 0.19.0. (Fixes: :issue:`817`) v0.19.3 (2014-08-03) From 9b7bcd37b3d00134d22382b2a75881cb55cf7d37 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 5 Aug 2014 23:58:03 +0200 Subject: [PATCH 05/24] docs: Add note Debian package distro support (fixes #820) --- docs/installation/debian.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/installation/debian.rst b/docs/installation/debian.rst index 26864986..f34eb255 100644 --- a/docs/installation/debian.rst +++ b/docs/installation/debian.rst @@ -14,6 +14,22 @@ instructions should work for you as well. If you're setting up a Raspberry Pi from scratch, we have a guide for installing Debian/Raspbian and Mopidy. See :ref:`raspberrypi-installation`. +.. note:: + + The packages should work with: + + - Debian stable and testing, + - Raspbian stable and testing, + - Ubuntu 14.04 LTS and later. + + Some of the packages, including the core "mopidy" packages, does *not* work + on Ubuntu 12.04 LTS. + + This is just what we currently support, not a promise to continue to + support the same in the future. We *will* drop support for older + distributions when supporting those stops us from moving forward with the + project. + #. Add the archive's GPG key:: wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - From bac3bfb7a2e47634334c2adb8350e5005bccecf7 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 01:31:25 +0200 Subject: [PATCH 06/24] log: Don't disable loggers when loading fileConfig The default when loading config for logging from a file is to disable existing loggers. Since some loggers are created before logging is set up, these loggers were disabled if logging/config_file is set. (cherry picked from commit cb0387c46d7c65d141355ce716764f7b05ef3f3f) Conflicts: docs/changelog.rst --- docs/changelog.rst | 3 +++ mopidy/utils/log.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c0d48ec4..eddf10b7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -14,6 +14,9 @@ Bug fix release. arguments. This was incorrectly returning artists after the MPD command changes in 0.19.0. (Fixes: :issue:`817`) +- Logging: Fix that some loggers would be disabled if logging/config_file was + set. + v0.19.3 (2014-08-03) ==================== diff --git a/mopidy/utils/log.py b/mopidy/utils/log.py index 5d6d3635..c461b434 100644 --- a/mopidy/utils/log.py +++ b/mopidy/utils/log.py @@ -47,7 +47,8 @@ def setup_logging(config, verbosity_level, save_debug_log): if config['logging']['config_file']: # Logging config from file must be read before other handlers are # added. If not, the other handlers will have no effect. - logging.config.fileConfig(config['logging']['config_file']) + logging.config.fileConfig(config['logging']['config_file'], + disable_existing_loggers=False) setup_console_logging(config, verbosity_level) if save_debug_log: From 44c79515207aace013cae24d18509c17893609ca Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 12:48:56 +0200 Subject: [PATCH 07/24] docs: Use :confval:-syntax, add fixes for logging issue (cherry picked from commit 524043f6b7ee4c3120d6e7e00bad154e4ad82668) Conflicts: docs/changelog.rst --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index eddf10b7..8409054a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -14,8 +14,8 @@ Bug fix release. arguments. This was incorrectly returning artists after the MPD command changes in 0.19.0. (Fixes: :issue:`817`) -- Logging: Fix that some loggers would be disabled if logging/config_file was - set. +- Logging: Fix that some loggers would be disabled if + :confval:`logging/config_file` was set. (Fixes: :issue:`740`) v0.19.3 (2014-08-03) From 0863a813fafc67ce785204c27f77452584a6cf2d Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 13:43:18 +0200 Subject: [PATCH 08/24] main: Return status code 1 if {Backend,Frontend,Mixer}Error is raised --- mopidy/commands.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mopidy/commands.py b/mopidy/commands.py index f7c71d4e..db012208 100644 --- a/mopidy/commands.py +++ b/mopidy/commands.py @@ -276,8 +276,10 @@ class RootCommand(Command): exceptions.FrontendError, exceptions.MixerError): logger.info('Initialization error. Exiting...') + exit_status_code = 1 except KeyboardInterrupt: logger.info('Interrupted. Exiting...') + exit_status_code = 0 finally: loop.quit() self.stop_frontends(frontend_classes) @@ -286,6 +288,7 @@ class RootCommand(Command): self.stop_audio() self.stop_mixer(mixer_class) process.stop_remaining_actors() + return exit_status_code def get_mixer_class(self, config, mixer_classes): logger.debug( From 9e41eff187b68a19375ce7c79b5967f7b2699e60 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 14:48:04 +0200 Subject: [PATCH 09/24] config: Support passing directories to mopidy --config --- docs/changelog.rst | 2 ++ mopidy/config/__init__.py | 40 ++++++++++++++++++++++-------------- tests/config/test_config.py | 6 ++++++ tests/data/conf.d/file1.conf | 2 ++ tests/data/conf.d/file2.conf | 2 ++ 5 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 tests/data/conf.d/file1.conf create mode 100644 tests/data/conf.d/file2.conf diff --git a/docs/changelog.rst b/docs/changelog.rst index 8409054a..42075ecd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,8 @@ Bug fix release. - Logging: Fix that some loggers would be disabled if :confval:`logging/config_file` was set. (Fixes: :issue:`740`) +- Configuration: :option:`mopidy --config` now supports directories. + v0.19.3 (2014-08-03) ==================== diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 3b63a1ab..09cdc0ca 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -116,21 +116,14 @@ def _load(files, defaults, overrides): parser.readfp(io.BytesIO(default)) # Load config from a series of config files - for filename in files: - try: - with io.open(filename, 'rb') as filehandle: - parser.readfp(filehandle) - except configparser.MissingSectionHeaderError as e: - logger.warning('%s does not have a config section, not loaded.', - filename) - except configparser.ParsingError as e: - linenos = ', '.join(str(lineno) for lineno, line in e.errors) - logger.warning( - '%s has errors, line %s has been ignored.', filename, linenos) - except IOError: - # TODO: if this is the initial load of logging config we might not - # have a logger at this point, we might want to handle this better. - logger.debug('Config file %s not found; skipping', filename) + for name in files: + if os.path.isdir(name): + for filename in os.listdir(name): + filename = os.path.join(name, filename) + if os.path.isfile(filename): + _load_file(parser, filename) + else: + _load_file(parser, name) # If there have been parse errors there is a python bug that causes the # values to be lists, this little trick coerces these into strings. @@ -146,6 +139,23 @@ def _load(files, defaults, overrides): return raw_config +def _load_file(parser, filename): + try: + with io.open(filename, 'rb') as filehandle: + parser.readfp(filehandle) + except configparser.MissingSectionHeaderError as e: + logger.warning('%s does not have a config section, not loaded.', + filename) + except configparser.ParsingError as e: + linenos = ', '.join(str(lineno) for lineno, line in e.errors) + logger.warning( + '%s has errors, line %s has been ignored.', filename, linenos) + except IOError: + # TODO: if this is the initial load of logging config we might not + # have a logger at this point, we might want to handle this better. + logger.debug('Config file %s not found; skipping', filename) + + def _validate(raw_config, schemas): # Get validated config config = {} diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 52035825..6a0ee12b 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -60,6 +60,12 @@ class LoadConfigTest(unittest.TestCase): result = config._load([file1, file2], [], []) self.assertEqual(expected, result) + def test_load_directory(self): + directory = path_to_data_dir('conf.d') + expected = {'foo': {'bar': 'baz'}, 'foo2': {'bar': 'baz'}} + result = config._load([directory], [], []) + self.assertEqual(expected, result) + def test_load_file_with_utf8(self): expected = {'foo': {'bar': 'æøå'.encode('utf-8')}} result = config._load([path_to_data_dir('file3.conf')], [], []) diff --git a/tests/data/conf.d/file1.conf b/tests/data/conf.d/file1.conf new file mode 100644 index 00000000..e6396bff --- /dev/null +++ b/tests/data/conf.d/file1.conf @@ -0,0 +1,2 @@ +[foo] +bar = baz diff --git a/tests/data/conf.d/file2.conf b/tests/data/conf.d/file2.conf new file mode 100644 index 00000000..ef189703 --- /dev/null +++ b/tests/data/conf.d/file2.conf @@ -0,0 +1,2 @@ +[foo2] +bar = baz From 4ea5271362ebbaa7015a7a993f9b230334842d53 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 16:13:40 +0200 Subject: [PATCH 10/24] docs: Return exit status 1 on initialization error --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8409054a..8fdbb8ba 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,8 @@ Bug fix release. - Logging: Fix that some loggers would be disabled if :confval:`logging/config_file` was set. (Fixes: :issue:`740`) +- Core: Return exit status 1 when exiting because of initialization error. + v0.19.3 (2014-08-03) ==================== From 584484379a9c98d9686e11fce821cd9681a4759b Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 16:21:34 +0200 Subject: [PATCH 11/24] config: Only load .conf-files when loading directories --- mopidy/config/__init__.py | 2 +- tests/config/test_config.py | 8 +++++++- tests/data/{conf.d => conf1.d}/file1.conf | 0 tests/data/{conf.d => conf1.d}/file2.conf | 0 tests/data/conf2.d/file1.conf | 2 ++ tests/data/conf2.d/file2.conf.disabled | 2 ++ 6 files changed, 12 insertions(+), 2 deletions(-) rename tests/data/{conf.d => conf1.d}/file1.conf (100%) rename tests/data/{conf.d => conf1.d}/file2.conf (100%) create mode 100644 tests/data/conf2.d/file1.conf create mode 100644 tests/data/conf2.d/file2.conf.disabled diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 09cdc0ca..5611c717 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -120,7 +120,7 @@ def _load(files, defaults, overrides): if os.path.isdir(name): for filename in os.listdir(name): filename = os.path.join(name, filename) - if os.path.isfile(filename): + if os.path.isfile(filename) and filename.endswith('.conf'): _load_file(parser, filename) else: _load_file(parser, name) diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 6a0ee12b..da0e5192 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -61,11 +61,17 @@ class LoadConfigTest(unittest.TestCase): self.assertEqual(expected, result) def test_load_directory(self): - directory = path_to_data_dir('conf.d') + directory = path_to_data_dir('conf1.d') expected = {'foo': {'bar': 'baz'}, 'foo2': {'bar': 'baz'}} result = config._load([directory], [], []) self.assertEqual(expected, result) + def test_load_directory_only_conf_files(self): + directory = path_to_data_dir('conf2.d') + expected = {'foo': {'bar': 'baz'}} + result = config._load([directory], [], []) + self.assertEqual(expected, result) + def test_load_file_with_utf8(self): expected = {'foo': {'bar': 'æøå'.encode('utf-8')}} result = config._load([path_to_data_dir('file3.conf')], [], []) diff --git a/tests/data/conf.d/file1.conf b/tests/data/conf1.d/file1.conf similarity index 100% rename from tests/data/conf.d/file1.conf rename to tests/data/conf1.d/file1.conf diff --git a/tests/data/conf.d/file2.conf b/tests/data/conf1.d/file2.conf similarity index 100% rename from tests/data/conf.d/file2.conf rename to tests/data/conf1.d/file2.conf diff --git a/tests/data/conf2.d/file1.conf b/tests/data/conf2.d/file1.conf new file mode 100644 index 00000000..e6396bff --- /dev/null +++ b/tests/data/conf2.d/file1.conf @@ -0,0 +1,2 @@ +[foo] +bar = baz diff --git a/tests/data/conf2.d/file2.conf.disabled b/tests/data/conf2.d/file2.conf.disabled new file mode 100644 index 00000000..ef189703 --- /dev/null +++ b/tests/data/conf2.d/file2.conf.disabled @@ -0,0 +1,2 @@ +[foo2] +bar = baz From d776ada30ad94314adfa456dc5d6f607f65cbc08 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Mon, 11 Aug 2014 16:27:19 +0200 Subject: [PATCH 12/24] docs: Add directories to --config in man page --- docs/command.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/command.rst b/docs/command.rst index 79ca3ed0..8ef7414b 100644 --- a/docs/command.rst +++ b/docs/command.rst @@ -50,11 +50,12 @@ Options Save debug log to the file specified in the :confval:`logging/debug_file` config value, typically ``./mopidy.log``. -.. cmdoption:: --config +.. cmdoption:: --config - Specify config file to use. To use multiple config files, separate them - with a colon. The later files override the earlier ones if there's a - conflict. + Specify config files and directories to use. To use multiple config files + or directories, separate them with a colon. The later files override the + earlier ones if there's a conflict. When specifying a directory, all files + ending in .conf in the directory is used. .. cmdoption:: --option