From 46177f65f11d53a61c055ea0cf16a2e5ee342ff0 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 10 Aug 2010 21:45:01 +0200 Subject: [PATCH] Rename mopidy.backends.{gstreamer => local} --- docs/api/backends.rst | 17 ++++----- docs/changes.rst | 1 + docs/development/roadmap.rst | 2 +- docs/installation/gstreamer.rst | 13 ++++--- docs/installation/index.rst | 33 +++++++++++----- docs/installation/libspotify.rst | 11 ------ .../backends/{gstreamer => local}/__init__.py | 38 ++++++++----------- .../{gstreamer_test.py => local_test.py} | 26 ++++++------- 8 files changed, 69 insertions(+), 72 deletions(-) rename mopidy/backends/{gstreamer => local}/__init__.py (88%) rename tests/backends/{gstreamer_test.py => local_test.py} (86%) diff --git a/docs/api/backends.rst b/docs/api/backends.rst index 6760fc54..adb87e56 100644 --- a/docs/api/backends.rst +++ b/docs/api/backends.rst @@ -98,18 +98,17 @@ Manages the music library, e.g. searching for tracks to be added to a playlist. :members: -:mod:`mopidy.backends.gstreamer` -- GStreamer backend -===================================================== - -.. automodule:: mopidy.backends.gstreamer - :synopsis: Backend for playing music from a local music archive using the - GStreamer library - :members: - - :mod:`mopidy.backends.libspotify` -- Libspotify backend ======================================================= .. automodule:: mopidy.backends.libspotify :synopsis: Spotify backend using the libspotify library :members: + + +:mod:`mopidy.backends.local` -- Local backend +===================================================== + +.. automodule:: mopidy.backends.local + :synopsis: Backend for playing music files on local storage + :members: diff --git a/docs/changes.rst b/docs/changes.rst index 2e765176..8c034f51 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -15,6 +15,7 @@ Another great release. - Exit early if not Python >= 2.6, < 3. - Include Sphinx scripts for building docs, pylintrc, tests and test data in the packages created by ``setup.py`` for i.e. PyPI. +- Rename :mod:`mopidy.backends.gstreamer` to :mod:`mopidy.backends.local`. - MPD frontend: - Relocate from :mod:`mopidy.mpd` to :mod:`mopidy.frontends.mpd`. diff --git a/docs/development/roadmap.rst b/docs/development/roadmap.rst index 32d52ec5..7dc284df 100644 --- a/docs/development/roadmap.rst +++ b/docs/development/roadmap.rst @@ -14,7 +14,7 @@ Version 0.1 - Read-only support for Spotify through :mod:`mopidy.backends.despotify` and/or :mod:`mopidy.backends.libspotify`. - Initial support for local file playback through - :mod:`mopidy.backends.gstreamer`. The state of local file playback will not + :mod:`mopidy.backends.local`. The state of local file playback will not block the release of 0.1. diff --git a/docs/installation/gstreamer.rst b/docs/installation/gstreamer.rst index a5b30d0e..dd038ba0 100644 --- a/docs/installation/gstreamer.rst +++ b/docs/installation/gstreamer.rst @@ -29,11 +29,12 @@ To install Gstreamer on OS X using MacPorts:: gstreamer-plugins-ugly -Setting up Mopidy to use the Gstreamer backend -============================================== +Testing the installation +======================== -Currently :mod:`mopidy.backends.despotify` is the default -backend. If you want to use :mod:`mopidy.backends.gstreamer` -instead, add the following to ``~/.mopidy/settings.py``:: +If you now run the ``gst-inspect-0.10`` command (the version number may vary), +you should see a long listing of installed plugins, ending in a summary line:: - BACKENDS = (u'mopidy.backends.gstreamer.GstreamerBackend',) + $ gst-inspect-0.10 + ... long list of installed plugins ... + Total count: 218 plugins (1 blacklist entry not shown), 1031 features diff --git a/docs/installation/index.rst b/docs/installation/index.rst index 863e465c..b7601c3a 100644 --- a/docs/installation/index.rst +++ b/docs/installation/index.rst @@ -35,15 +35,15 @@ Dependencies - DespotifyBackend (Linux and OS X) - - see :doc:`despotify` + - :doc:`Despotify and spytify ` - - LibspotifyBackend (Linux, OS X and Windows) + - LibspotifyBackend (Linux, OS X, and Windows) - - see :doc:`libspotify` + - :doc:`libspotify and pyspotify ` - - GstreamerBackend (Linux, OS X and Windows) + - LocalBackend (Linux, OS X, and Windows) - - see :doc:`gstreamer` + - :doc:`GStreamer ` Install latest release @@ -84,15 +84,30 @@ For an introduction to ``git``, please visit `git-scm.com `_. -Spotify settings -================ +Settings +======== -Create a file named ``settings.py`` in the directory ``~/.mopidy/``. Enter -your Spotify Premium account's username and password into the file, like this:: +Create a file named ``settings.py`` in the directory ``~/.mopidy/``. + +If you are using a Spotify backend, enter your Spotify Premium account's +username and password into the file, like this:: SPOTIFY_USERNAME = u'myusername' SPOTIFY_PASSWORD = u'mysecret' +Currently :mod:`mopidy.backends.despotify` is the default +backend. + +If you want to use :mod:`mopidy.backends.libspotify`, copy the Spotify +application key to ``~/.mopidy/spotify_appkey.key``, and add the following +setting:: + + BACKENDS = (u'mopidy.backends.libspotify.LibspotifyBackend',) + +If you want to use :mod:`mopidy.backends.local`, add the following setting:: + + BACKENDS = (u'mopidy.backends.local.LocalBackend',) + For a full list of available settings, see :mod:`mopidy.settings`. diff --git a/docs/installation/libspotify.rst b/docs/installation/libspotify.rst index 71873b01..f595a5cb 100644 --- a/docs/installation/libspotify.rst +++ b/docs/installation/libspotify.rst @@ -54,14 +54,3 @@ Testing the installation Test your libspotify setup:: examples/example1.py -u USERNAME -p PASSWORD - - -Setting up Mopidy to use libspotify -=================================== - -Currently :mod:`mopidy.backends.despotify` is the default -backend. If you want to use :mod:`mopidy.backends.libspotify` -instead, copy the Spotify application key to ``~/.mopidy/spotify_appkey.key``, -and add the following to ``~/.mopidy/settings.py``:: - - BACKENDS = (u'mopidy.backends.libspotify.LibspotifyBackend',) diff --git a/mopidy/backends/gstreamer/__init__.py b/mopidy/backends/local/__init__.py similarity index 88% rename from mopidy/backends/gstreamer/__init__.py rename to mopidy/backends/local/__init__.py index 74dd8332..87d2f7c0 100644 --- a/mopidy/backends/gstreamer/__init__.py +++ b/mopidy/backends/local/__init__.py @@ -19,38 +19,36 @@ from mopidy.models import Playlist, Track, Album from mopidy import settings from mopidy.utils import parse_m3u, parse_mpd_tag_cache -logger = logging.getLogger(u'backends.gstreamer') +logger = logging.getLogger(u'mopidy.backends.local') -class GStreamerMessages(threading.Thread): +class LocalMessages(threading.Thread): def run(self): gobject.MainLoop().run() -message_thread = GStreamerMessages() +message_thread = LocalMessages() message_thread.daemon = True message_thread.start() -class GStreamerBackend(BaseBackend): +class LocalBackend(BaseBackend): """ A backend for playing music from a local music archive. - Uses the `GStreamer `_ library. - - **Issues:** http://github.com/jodal/mopidy/issues/labels/backend-gstreamer + **Issues:** http://github.com/jodal/mopidy/issues/labels/backend-local """ def __init__(self, *args, **kwargs): - super(GStreamerBackend, self).__init__(*args, **kwargs) + super(LocalBackend, self).__init__(*args, **kwargs) - self.library = GStreamerLibraryController(self) - self.stored_playlists = GStreamerStoredPlaylistsController(self) + self.library = LocalLibraryController(self) + self.stored_playlists = LocalStoredPlaylistsController(self) self.current_playlist = BaseCurrentPlaylistController(self) - self.playback = GStreamerPlaybackController(self) + self.playback = LocalPlaybackController(self) self.uri_handlers = [u'file://'] -class GStreamerPlaybackController(BasePlaybackController): +class LocalPlaybackController(BasePlaybackController): def __init__(self, backend): - super(GStreamerPlaybackController, self).__init__(backend) + super(LocalPlaybackController, self).__init__(backend) self._bin = gst.element_factory_make("playbin", "player") self._bus = self._bin.get_bus() @@ -64,12 +62,6 @@ class GStreamerPlaybackController(BasePlaybackController): self.stop() - def use_fake_sink(self): - """For testing. To avoid audio output during testing, and the need for - a sound card and a fully working gstreamer installation.""" - sink = gst.element_factory_make("fakesink", "fakesink") - self._bin.set_property("audio-sink", sink) - def _set_state(self, state): self._bin.set_state(state) (_, new, _) = self._bin.get_state() @@ -124,9 +116,9 @@ class GStreamerPlaybackController(BasePlaybackController): del playbin -class GStreamerStoredPlaylistsController(BaseStoredPlaylistsController): +class LocalStoredPlaylistsController(BaseStoredPlaylistsController): def __init__(self, *args): - super(GStreamerStoredPlaylistsController, self).__init__(*args) + super(LocalStoredPlaylistsController, self).__init__(*args) self._folder = os.path.expanduser(settings.LOCAL_PLAYLIST_FOLDER) self.refresh() @@ -197,9 +189,9 @@ class GStreamerStoredPlaylistsController(BaseStoredPlaylistsController): self._playlists.append(playlist) -class GStreamerLibraryController(BaseLibraryController): +class LocalLibraryController(BaseLibraryController): def __init__(self, backend): - super(GStreamerLibraryController, self).__init__(backend) + super(LocalLibraryController, self).__init__(backend) self._uri_mapping = {} self.refresh() diff --git a/tests/backends/gstreamer_test.py b/tests/backends/local_test.py similarity index 86% rename from tests/backends/gstreamer_test.py rename to tests/backends/local_test.py index 22619c80..63282bde 100644 --- a/tests/backends/gstreamer_test.py +++ b/tests/backends/local_test.py @@ -1,14 +1,14 @@ import unittest import os -# FIXME Our Windows build server does not support Gstreamer yet +# FIXME Our Windows build server does not support GStreamer yet import sys if sys.platform == 'win32': from tests import SkipTest raise SkipTest from mopidy import settings -from mopidy.backends.gstreamer import GStreamerBackend +from mopidy.backends.local import LocalBackend from mopidy.mixers.dummy import DummyMixer from mopidy.models import Playlist, Track from mopidy.utils import path_to_uri @@ -21,22 +21,22 @@ generate_song = lambda i: path_to_uri(song % i) # FIXME can be switched to generic test -class GStreamerCurrentPlaylistControllerTest(BaseCurrentPlaylistControllerTest, +class LocalCurrentPlaylistControllerTest(BaseCurrentPlaylistControllerTest, unittest.TestCase): tracks = [Track(uri=generate_song(i), length=4464) for i in range(1, 4)] - backend_class = GStreamerBackend + backend_class = LocalBackend -class GStreamerPlaybackControllerTest(BasePlaybackControllerTest, +class LocalPlaybackControllerTest(BasePlaybackControllerTest, unittest.TestCase): tracks = [Track(uri=generate_song(i), length=4464) for i in range(1, 4)] - backend_class = GStreamerBackend + backend_class = LocalBackend def setUp(self): - super(GStreamerPlaybackControllerTest, self).setUp() + super(LocalPlaybackControllerTest, self).setUp() # Two tests does not work at all when using the fake sink #self.backend.playback.use_fake_sink() @@ -64,10 +64,10 @@ class GStreamerPlaybackControllerTest(BasePlaybackControllerTest, self.assertEqual(self.playback.state, self.playback.PLAYING) -class GStreamerStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest, +class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest, unittest.TestCase): - backend_class = GStreamerBackend + backend_class = LocalBackend def test_created_playlist_is_persisted(self): path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u') @@ -136,10 +136,10 @@ class GStreamerStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest, raise SkipTest -class GStreamerLibraryControllerTest(BaseLibraryControllerTest, +class LocalLibraryControllerTest(BaseLibraryControllerTest, unittest.TestCase): - backend_class = GStreamerBackend + backend_class = LocalBackend def setUp(self): self.original_tag_cache = settings.LOCAL_TAG_CACHE @@ -148,13 +148,13 @@ class GStreamerLibraryControllerTest(BaseLibraryControllerTest, settings.LOCAL_TAG_CACHE = data_folder('library_tag_cache') settings.LOCAL_MUSIC_FOLDER = data_folder('') - super(GStreamerLibraryControllerTest, self).setUp() + super(LocalLibraryControllerTest, self).setUp() def tearDown(self): settings.LOCAL_TAG_CACHE = self.original_tag_cache settings.LOCAL_MUSIC_FOLDER = self.original_music_folder - super(GStreamerLibraryControllerTest, self).tearDown() + super(LocalLibraryControllerTest, self).tearDown() if __name__ == '__main__': unittest.main()