Merge branch 'develop' into feature/implement-gapless

Conflicts:
	tests/local/test_playback.py
This commit is contained in:
Thomas Adamcik 2015-09-04 14:15:32 +02:00
commit d8ce171b9a
7 changed files with 290 additions and 343 deletions

View File

@ -31,6 +31,8 @@ v1.1.1 (UNRELEASED)
Bug fix release.
- Dependencies: Specify that we need Requests >= 2.0, not just any version.
- Core: Make :meth:`mopidy.core.LibraryController.refresh` work for all
backends with a library provider. Previously, it wrongly worked for all
backends with a playlists provider. (Fixes: :issue:`1257`)
@ -47,6 +49,12 @@ Bug fix release.
- Core: Fix error in :meth:`~mopidy.core.TracklistController.get_eot_tlid`
docstring. (Fixes: :issue:`1269`)
- Extension support: Make :meth:`~mopidy.ext.Extension.get_cache_dir`,
:meth:`~mopidy.ext.Extension.get_config_dir`, and
:meth:`~mopidy.ext.Extension.get_data_dir` class methods, so they can be used
without creating an instance of the :class:`~mopidy.ext.Extension` class.
(Fixes: :issue:`1275`)
- Local: Deprecate :confval:`local/data_dir` and respect
:confval:`core/data_dir` instead. This does not change the defaults for
desktop users, only system services installed from packages that properly set

View File

@ -60,7 +60,8 @@ class Extension(object):
schema['enabled'] = config_lib.Boolean()
return schema
def get_cache_dir(self, config):
@classmethod
def get_cache_dir(cls, config):
"""Get or create cache directory for the extension.
Use this directory to cache data that can safely be thrown away.
@ -68,25 +69,27 @@ class Extension(object):
:param config: the Mopidy config object
:return: string
"""
assert self.ext_name is not None
assert cls.ext_name is not None
cache_dir_path = bytes(os.path.join(config['core']['cache_dir'],
self.ext_name))
cls.ext_name))
path.get_or_create_dir(cache_dir_path)
return cache_dir_path
def get_config_dir(self, config):
@classmethod
def get_config_dir(cls, config):
"""Get or create configuration directory for the extension.
:param config: the Mopidy config object
:return: string
"""
assert self.ext_name is not None
assert cls.ext_name is not None
config_dir_path = bytes(os.path.join(config['core']['config_dir'],
self.ext_name))
cls.ext_name))
path.get_or_create_dir(config_dir_path)
return config_dir_path
def get_data_dir(self, config):
@classmethod
def get_data_dir(cls, config):
"""Get or create data directory for the extension.
Use this directory to store data that should be persistent.
@ -94,9 +97,9 @@ class Extension(object):
:param config: the Mopidy config object
:returns: string
"""
assert self.ext_name is not None
assert cls.ext_name is not None
data_dir_path = bytes(os.path.join(config['core']['data_dir'],
self.ext_name))
cls.ext_name))
path.get_or_create_dir(data_dir_path)
return data_dir_path

View File

@ -12,7 +12,7 @@ import tempfile
import mopidy
from mopidy import compat, local, models
from mopidy.internal import encoding, timer
from mopidy.local import Extension, search, storage, translator
from mopidy.local import search, storage, translator
logger = logging.getLogger(__name__)
@ -116,7 +116,7 @@ class JsonLibrary(local.Library):
self._browse_cache = None
self._media_dir = config['local']['media_dir']
self._json_file = os.path.join(
Extension().get_data_dir(config), b'library.json.gz')
local.Extension.get_data_dir(config), b'library.json.gz')
storage.check_dirs_and_files(config)

View File

@ -30,7 +30,7 @@ class M3UBackend(pykka.ThreadingActor, backend.Backend):
'Could not create M3U playlists dir: %s',
encoding.locale_decode(error))
else:
self._playlists_dir = m3u.Extension().get_data_dir(config)
self._playlists_dir = m3u.Extension.get_data_dir(config)
self.playlists = M3UPlaylistsProvider(backend=self)
self.library = M3ULibraryProvider(backend=self)

View File

@ -25,7 +25,7 @@ setup(
include_package_data=True,
install_requires=[
'Pykka >= 1.1',
'requests',
'requests >= 2.0',
'setuptools',
'tornado >= 2.3',
],

File diff suppressed because it is too large Load Diff

View File

@ -58,17 +58,17 @@ class TestExtension(object):
def test_get_cache_dir_raises_assertion_error(self, extension):
config = {'core': {'cache_dir': '/tmp'}}
with pytest.raises(AssertionError): # ext_name not set
extension.get_cache_dir(config)
ext.Extension.get_cache_dir(config)
def test_get_config_dir_raises_assertion_error(self, extension):
config = {'core': {'config_dir': '/tmp'}}
with pytest.raises(AssertionError): # ext_name not set
extension.get_config_dir(config)
ext.Extension.get_config_dir(config)
def test_get_data_dir_raises_assertion_error(self, extension):
config = {'core': {'data_dir': '/tmp'}}
with pytest.raises(AssertionError): # ext_name not set
extension.get_data_dir(config)
ext.Extension.get_data_dir(config)
class TestLoadExtensions(object):