From e2b4a2749baf39ceb8c58015bc228fdcd2fb7096 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 15 Oct 2018 22:41:08 +0200 Subject: [PATCH 1/8] Update MANIFEST.in to include .github and exclude .doctrees --- MANIFEST.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index b2b7f37c..5eb0eaa3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,8 +8,11 @@ include LICENSE include MANIFEST.in include tox.ini +recursive-include .github * + recursive-include docs * prune docs/_build +prune docs/.doctrees recursive-include extra * From 1d30e73ab0c7e56c8b83616ee27aa81f35f23cd5 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Sat, 20 Oct 2018 18:20:38 +0100 Subject: [PATCH 2/8] http: use current Tornado IOLoop when stopping. (Fixes #1715). This is in response to the breaking change in Tornado v5.0 where IOLoop.instance is now a deprecated alias for IOLoop.current. More info at https://www.tornadoweb.org/en/stable/releases/v5.0.0.html --- docs/changelog.rst | 7 +++++++ mopidy/http/actor.py | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b6d7d1b6..a8cc3e65 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,13 @@ Changelog This changelog is used to track all major changes to Mopidy. +v2.2.2 (UNRELEASED) +=================== + +- HTTP: Fix hang on exit due to change in Tornado v5.0 IOLoop. (Fixes: + :issue:`1715`, PR: :issue:`1716`) + + v2.2.1 (2018-10-15) =================== diff --git a/mopidy/http/actor.py b/mopidy/http/actor.py index 8b4835da..1e0e594c 100644 --- a/mopidy/http/actor.py +++ b/mopidy/http/actor.py @@ -100,20 +100,21 @@ class HttpServer(threading.Thread): self.app = None self.server = None + self.io_loop = None def run(self): self.app = tornado.web.Application(self._get_request_handlers()) self.server = tornado.httpserver.HTTPServer(self.app) self.server.add_sockets(self.sockets) - tornado.ioloop.IOLoop.instance().start() + self.io_loop = tornado.ioloop.IOLoop.current() + self.io_loop.start() logger.debug('Stopped HTTP server') def stop(self): logger.debug('Stopping HTTP server') - tornado.ioloop.IOLoop.instance().add_callback( - tornado.ioloop.IOLoop.instance().stop) + self.io_loop.add_callback(self.io_loop.stop) def _get_request_handlers(self): request_handlers = [] From c94b9d5fd23a5a8d1326a20348c2118e12fe4d72 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 26 Nov 2018 22:33:59 +0100 Subject: [PATCH 3/8] xdg: Read paths from user-dirs.dirs as bytes Fixes #1676, #1725 --- docs/changelog.rst | 5 +++++ mopidy/internal/xdg.py | 15 ++++++++------- tests/internal/test_xdg.py | 20 ++++++++++++-------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index a8cc3e65..48177be4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,9 +8,14 @@ This changelog is used to track all major changes to Mopidy. v2.2.2 (UNRELEASED) =================== +Bug fix release. + - HTTP: Fix hang on exit due to change in Tornado v5.0 IOLoop. (Fixes: :issue:`1715`, PR: :issue:`1716`) +- Files: Fix crash due to mix of text and bytes in paths that come from + ``$XDG_CONFIG_HOME/user-dirs.dirs``. (Fixes: :issue:`1676`, :issue:`1725`) + v2.2.1 (2018-10-15) =================== diff --git a/mopidy/internal/xdg.py b/mopidy/internal/xdg.py index 4b5855f1..7b377599 100644 --- a/mopidy/internal/xdg.py +++ b/mopidy/internal/xdg.py @@ -53,15 +53,16 @@ def _get_user_dirs(xdg_config_dir): return {} with open(dirs_file, 'rb') as fh: - data = fh.read().decode('utf-8') + data = fh.read() - data = '[XDG_USER_DIRS]\n' + data - data = data.replace('$HOME', os.path.expanduser('~')) - data = data.replace('"', '') + data = b'[XDG_USER_DIRS]\n' + data + data = data.replace(b'$HOME', os.path.expanduser(b'~')) + data = data.replace(b'"', b'') config = configparser.RawConfigParser() - config.readfp(io.StringIO(data)) + config.readfp(io.BytesIO(data)) return { - k.upper(): os.path.abspath(v) - for k, v in config.items('XDG_USER_DIRS') if v is not None} + k.upper().decode('utf-8'): os.path.abspath(v) + for k, v in config.items('XDG_USER_DIRS') if v is not None + } diff --git a/tests/internal/test_xdg.py b/tests/internal/test_xdg.py index 521447f7..94d1aa81 100644 --- a/tests/internal/test_xdg.py +++ b/tests/internal/test_xdg.py @@ -21,9 +21,10 @@ def test_cache_dir_default(environ): def test_cache_dir_from_env(environ): - os.environ['XDG_CACHE_HOME'] = '/foo/bar' + os.environ['XDG_CACHE_HOME'] = b'/foo/bar' - assert xdg.get_dirs()['XDG_CACHE_DIR'] == '/foo/bar' + assert xdg.get_dirs()['XDG_CACHE_DIR'] == b'/foo/bar' + assert type(xdg.get_dirs()['XDG_CACHE_DIR']) == bytes def test_config_dir_default(environ): @@ -31,9 +32,10 @@ def test_config_dir_default(environ): def test_config_dir_from_env(environ): - os.environ['XDG_CONFIG_HOME'] = '/foo/bar' + os.environ['XDG_CONFIG_HOME'] = b'/foo/bar' - assert xdg.get_dirs()['XDG_CONFIG_DIR'] == '/foo/bar' + assert xdg.get_dirs()['XDG_CONFIG_DIR'] == b'/foo/bar' + assert type(xdg.get_dirs()['XDG_CONFIG_DIR']) == bytes def test_data_dir_default(environ): @@ -42,21 +44,23 @@ def test_data_dir_default(environ): def test_data_dir_from_env(environ): - os.environ['XDG_DATA_HOME'] = '/foo/bar' + os.environ['XDG_DATA_HOME'] = b'/foo/bar' - assert xdg.get_dirs()['XDG_DATA_DIR'] == '/foo/bar' + assert xdg.get_dirs()['XDG_DATA_DIR'] == b'/foo/bar' + assert type(xdg.get_dirs()['XDG_DATA_DIR']) == bytes def test_user_dirs(environ, tmpdir): os.environ['XDG_CONFIG_HOME'] = str(tmpdir) with open(os.path.join(str(tmpdir), 'user-dirs.dirs'), 'wb') as fh: - fh.write('# Some comments\n') - fh.write('XDG_MUSIC_DIR="$HOME/Music2"\n') + fh.write(b'# Some comments\n') + fh.write(b'XDG_MUSIC_DIR="$HOME/Music2"\n') result = xdg.get_dirs() assert result['XDG_MUSIC_DIR'] == os.path.expanduser(b'~/Music2') + assert type(result['XDG_MUSIC_DIR']) == bytes assert 'XDG_DOWNLOAD_DIR' not in result From b34bcd0f58be598822992f12cc897c1c66d8e98d Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 2 Dec 2018 00:23:22 +0100 Subject: [PATCH 4/8] flake8: Ignore W504 It is ignored by default, but we must redefine the ignore since we specify what warnings are ignored ourselves. --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 95211279..1bc167c3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,8 @@ application-import-names = mopidy,tests exclude = .git,.tox,build,js,tmp # Ignored flake8 warnings: # - E402 module level import not at top of file -ignore = E402 +# - W504 line break after binary operator +ignore = E402, W504 [wheel] universal = 1 From 52a035d217a18d854985fed3f3788038799f5a02 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 2 Dec 2018 00:28:25 +0100 Subject: [PATCH 5/8] flake8: Fix new warnings from flake8 2.4.0 --- mopidy/mpd/protocol/__init__.py | 4 ++-- tasks.py | 4 ++-- tests/__init__.py | 2 +- tests/mpd/protocol/test_regression.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mopidy/mpd/protocol/__init__.py b/mopidy/mpd/protocol/__init__.py index 99294f4d..aab8ed8d 100644 --- a/mopidy/mpd/protocol/__init__.py +++ b/mopidy/mpd/protocol/__init__.py @@ -38,7 +38,7 @@ def load_protocol_modules(): def INT(value): # noqa: N802 - """Converts a value that matches [+-]?\d+ into and integer.""" + r"""Converts a value that matches [+-]?\d+ into and integer.""" if value is None: raise ValueError('None is not a valid integer') # TODO: check for whitespace via value != value.strip()? @@ -46,7 +46,7 @@ def INT(value): # noqa: N802 def UINT(value): # noqa: N802 - """Converts a value that matches \d+ into an integer.""" + r"""Converts a value that matches \d+ into an integer.""" if value is None: raise ValueError('None is not a valid integer') if not value.isdigit(): diff --git a/tasks.py b/tasks.py index db7143a5..cc4f71b2 100644 --- a/tasks.py +++ b/tasks.py @@ -42,7 +42,7 @@ def watcher(task, *args, **kwargs): task(*args, **kwargs) try: run( - 'inotifywait -q -e create -e modify -e delete ' - '--exclude ".*\.(pyc|sw.)" -r docs/ mopidy/ tests/') + r'inotifywait -q -e create -e modify -e delete ' + r'--exclude ".*\.(pyc|sw.)" -r docs/ mopidy/ tests/') except KeyboardInterrupt: sys.exit() diff --git a/tests/__init__.py b/tests/__init__.py index 99806e97..c121a947 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -23,7 +23,7 @@ class IsA(object): try: return isinstance(rhs, self.klass) except TypeError: - return type(rhs) == type(self.klass) # flake8: noqa + return type(rhs) == type(self.klass) # noqa def __ne__(self, rhs): return not self.__eq__(rhs) diff --git a/tests/mpd/protocol/test_regression.py b/tests/mpd/protocol/test_regression.py index 40a3f103..156db777 100644 --- a/tests/mpd/protocol/test_regression.py +++ b/tests/mpd/protocol/test_regression.py @@ -161,7 +161,7 @@ class IssueGH69RegressionTest(protocol.BaseTestCase): class IssueGH113RegressionTest(protocol.BaseTestCase): - """ + r""" The issue: https://github.com/mopidy/mopidy/issues/113 How to reproduce: @@ -174,11 +174,11 @@ class IssueGH113RegressionTest(protocol.BaseTestCase): def test(self): self.core.playlists.create( - u'all lart spotify:track:\w\{22\} pastes') + r'all lart spotify:track:\w\{22\} pastes') self.send_request('lsinfo "/"') self.assertInResponse( - u'playlist: all lart spotify:track:\w\{22\} pastes') + r'playlist: all lart spotify:track:\w\{22\} pastes') self.send_request( r'listplaylistinfo "all lart spotify:track:\\w\\{22\\} pastes"') From dea1a428b2a225c5d3be7c799e5a5fe4e9398290 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 2 Dec 2018 00:31:59 +0100 Subject: [PATCH 6/8] travis: Build on xenial --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 648c3252..7c73868a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ -sudo: required -dist: trusty +dist: xenial language: python python: - - "2.7_with_system_site_packages" + - "2.7" + +virtualenv: + system_site_packages: true env: - TOX_ENV=py27 From bcdf8baea15f9594a17fce2146399c2b73d56ef5 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 29 Dec 2018 17:05:36 +0100 Subject: [PATCH 7/8] docs: Remove duplicate changelog --- docs/changelog.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e2451cf2..48177be4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,14 +4,6 @@ Changelog This changelog is used to track all major changes to Mopidy. -v2.2.2 (UNRELEASED) -=================== - -Bug fix release. - -- Files: Fix crash due to mix of text and bytes in paths that come from - ``$XDG_CONFIG_HOME/user-dirs.dirs``. (Fixes: :issue:`1676`, :issue:`1725`) - v2.2.2 (UNRELEASED) =================== From 1c227969942584e7d5ca8e11cb2cb765c7cb890f Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 29 Dec 2018 17:06:06 +0100 Subject: [PATCH 8/8] Bump version to v2.2.2 --- docs/changelog.rst | 2 +- mopidy/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 48177be4..fa2b3dcf 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,7 +5,7 @@ Changelog This changelog is used to track all major changes to Mopidy. -v2.2.2 (UNRELEASED) +v2.2.2 (2018-12-29) =================== Bug fix release. diff --git a/mopidy/__init__.py b/mopidy/__init__.py index 67658e48..cffc01b1 100644 --- a/mopidy/__init__.py +++ b/mopidy/__init__.py @@ -14,4 +14,4 @@ if not (2, 7) <= sys.version_info < (3,): warnings.filterwarnings('ignore', 'could not open display') -__version__ = '2.2.1' +__version__ = '2.2.2'