From 80f912535bb0f25d846c2a4315abbc48dd7dad13 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 8 Sep 2014 11:04:16 +0200 Subject: [PATCH 01/18] docs: Fix typo (cherry picked from commit 12f9860e2dd43fc726d10717ba4c900af90600f2) --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index bd324af7..395e683e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -63,7 +63,7 @@ channel at `irc.freenode.net `_. The IRC channel has If you stumble into a bug or have a feature request, please create an issue in the `issue tracker `_. If you're -unsure if its a bug or not, ask for help in the forum or at IRC first. The +unsure if it's a bug or not, ask for help in the forum or at IRC first. The `source code `_ may also be of help. If you want to stay up to date on Mopidy developments, you can follow `@mopidy From e79ecd378978ea2d48d47466fc83bd3ef654ff7f Mon Sep 17 00:00:00 2001 From: Dmitry Sandalov Date: Tue, 9 Sep 2014 11:10:05 +0400 Subject: [PATCH 02/18] fixes docs typo: AngularJS (cherry picked from commit 225092add5d7b1a2bf3f3fcf688023a4adead632) --- docs/ext/moped.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ext/moped.rst b/docs/ext/moped.rst index 38fa50cc..28254ed7 100644 --- a/docs/ext/moped.rst +++ b/docs/ext/moped.rst @@ -3,7 +3,7 @@ Moped https://github.com/martijnboland/moped -A Mopidy web client made with AnbularJS by Martijn Boland. +A Mopidy web client made with AngularJS by Martijn Boland. .. image:: /ext/moped.png :width: 720 From 523b4decc3266ef28106f4a4acc2fa38934a5c00 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 00:49:57 +0200 Subject: [PATCH 03/18] docs: Add Mopidy-Musicbox-Webclient to the web extensions list (cherry picked from commit eedaf0eb3b10a5bf02350a2608cc599f82475bfe) --- docs/clients/http.rst | 22 +----------------- .../musicbox_webclient.png} | Bin docs/ext/musicbox_webclient.rst | 21 +++++++++++++++++ docs/ext/web.rst | 3 +++ 4 files changed, 25 insertions(+), 21 deletions(-) rename docs/{clients/mopidy-musicbox-webclient.png => ext/musicbox_webclient.png} (100%) create mode 100644 docs/ext/musicbox_webclient.rst diff --git a/docs/clients/http.rst b/docs/clients/http.rst index bd7a39b0..5467f3b7 100644 --- a/docs/clients/http.rst +++ b/docs/clients/http.rst @@ -15,27 +15,7 @@ created one, please notify us so we can include your client on this page. See :ref:`http-api` for details on how to build your own web client. -Mopidy MusicBox Webclient -========================= - -.. image:: mopidy-musicbox-webclient.png - :width: 1275 - :height: 600 - -The first web client for Mopidy, made with jQuery Mobile by Wouter van Wijk. -Also the web client used for Wouter's popular `Pi Musicbox -`_ image for Raspberry Pi. - - With Mopidy MusicBox Webclient, you can play your music on your computer - (Raspberry Pi) and remotely control it from a computer, phone, tablet, - laptop. From your couch. - - This is a responsive HTML/JS/CSS client especially written for Mopidy, a - music server. Responsive, so it works on desktop and mobile browsers. You - can browse, search and play albums, artists, playlists, and it has cover - art from Last.fm. - - -- https://github.com/woutervanwijk/Mopidy-MusicBox-Webclient +.. include:: /ext/musicbox_webclient.rst .. include:: /ext/moped.rst diff --git a/docs/clients/mopidy-musicbox-webclient.png b/docs/ext/musicbox_webclient.png similarity index 100% rename from docs/clients/mopidy-musicbox-webclient.png rename to docs/ext/musicbox_webclient.png diff --git a/docs/ext/musicbox_webclient.rst b/docs/ext/musicbox_webclient.rst new file mode 100644 index 00000000..cdde6c10 --- /dev/null +++ b/docs/ext/musicbox_webclient.rst @@ -0,0 +1,21 @@ +Mopidy MusicBox Webclient +========================= + +.. image:: /ext/musicbox_webclient.png + :width: 1275 + :height: 600 + +The first web client for Mopidy, made with jQuery Mobile by Wouter van Wijk. +Also the web client used for Wouter's popular `Pi Musicbox +`_ image for Raspberry Pi. + + With Mopidy MusicBox Webclient, you can play your music on your computer + (Raspberry Pi) and remotely control it from a computer, phone, tablet, + laptop. From your couch. + + This is a responsive HTML/JS/CSS client especially written for Mopidy, a + music server. Responsive, so it works on desktop and mobile browsers. You + can browse, search and play albums, artists, playlists, and it has cover + art from Last.fm. + + -- https://github.com/woutervanwijk/Mopidy-MusicBox-Webclient diff --git a/docs/ext/web.rst b/docs/ext/web.rst index 7df054cd..e9a2bb02 100644 --- a/docs/ext/web.rst +++ b/docs/ext/web.rst @@ -16,3 +16,6 @@ to show up here, follow the :ref:`guide on creating extensions `. .. include:: /ext/moped.rst + + +.. include:: /ext/musicbox_webclient.rst From 3048d6bfbacdc734c898fec94f8bc73972840583 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 00:55:33 +0200 Subject: [PATCH 04/18] docs: More concistent format for web extensions (cherry picked from commit 249dcf92c46d5a7d215c87b834475b84b7881550) --- docs/ext/musicbox_webclient.rst | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/ext/musicbox_webclient.rst b/docs/ext/musicbox_webclient.rst index cdde6c10..b70c8e84 100644 --- a/docs/ext/musicbox_webclient.rst +++ b/docs/ext/musicbox_webclient.rst @@ -1,21 +1,14 @@ -Mopidy MusicBox Webclient +Mopidy-MusicBox-Webclient ========================= -.. image:: /ext/musicbox_webclient.png - :width: 1275 - :height: 600 +https://github.com/woutervanwijk/Mopidy-MusicBox-Webclient The first web client for Mopidy, made with jQuery Mobile by Wouter van Wijk. Also the web client used for Wouter's popular `Pi Musicbox `_ image for Raspberry Pi. - With Mopidy MusicBox Webclient, you can play your music on your computer - (Raspberry Pi) and remotely control it from a computer, phone, tablet, - laptop. From your couch. - This is a responsive HTML/JS/CSS client especially written for Mopidy, a - music server. Responsive, so it works on desktop and mobile browsers. You - can browse, search and play albums, artists, playlists, and it has cover - art from Last.fm. - -- https://github.com/woutervanwijk/Mopidy-MusicBox-Webclient +.. image:: /ext/musicbox_webclient.png + :width: 1275 + :height: 600 From bea04a7588f70394e3dee3d875e29214f1848a35 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 00:57:34 +0200 Subject: [PATCH 05/18] docs: Add install instructions for the web extensions (cherry picked from commit da18a599ac5a9c03931def4f6167e4000e0b3c0b) --- docs/ext/api_explorer.rst | 4 ++++ docs/ext/moped.rst | 8 ++++++-- docs/ext/musicbox_webclient.rst | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/ext/api_explorer.rst b/docs/ext/api_explorer.rst index 351ddf15..36e9dfb6 100644 --- a/docs/ext/api_explorer.rst +++ b/docs/ext/api_explorer.rst @@ -7,6 +7,10 @@ https://github.com/dz0ny/mopidy-api-explorer Web extension for browsing the Mopidy HTTP API. +To install, run:: + + pip install Mopidy-API-Explorer + .. image:: /ext/api_explorer.png :width: 1176 :height: 713 diff --git a/docs/ext/moped.rst b/docs/ext/moped.rst index 28254ed7..a05d550f 100644 --- a/docs/ext/moped.rst +++ b/docs/ext/moped.rst @@ -1,10 +1,14 @@ -Moped -===== +Mopidy-Moped +============ https://github.com/martijnboland/moped A Mopidy web client made with AngularJS by Martijn Boland. +To install, run:: + + pip install Mopidy-Moped + .. image:: /ext/moped.png :width: 720 :height: 450 diff --git a/docs/ext/musicbox_webclient.rst b/docs/ext/musicbox_webclient.rst index b70c8e84..afa78685 100644 --- a/docs/ext/musicbox_webclient.rst +++ b/docs/ext/musicbox_webclient.rst @@ -7,7 +7,9 @@ The first web client for Mopidy, made with jQuery Mobile by Wouter van Wijk. Also the web client used for Wouter's popular `Pi Musicbox `_ image for Raspberry Pi. +To install, run:: + pip install Mopidy-MusicBox-Webclient .. image:: /ext/musicbox_webclient.png :width: 1275 From 160a85513bdf2f340531ea5f7342c2526bb41264 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 01:01:32 +0200 Subject: [PATCH 06/18] docs: Add Mopidy-HTTP-Kuechenradio (cherry picked from commit 0e2866df307a8a1aa54879afea1ab3725fa7eacd) --- docs/clients/http.rst | 3 +++ docs/ext/kuechenradio.rst | 15 +++++++++++++++ docs/ext/web.rst | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 docs/ext/kuechenradio.rst diff --git a/docs/clients/http.rst b/docs/clients/http.rst index 5467f3b7..296a1886 100644 --- a/docs/clients/http.rst +++ b/docs/clients/http.rst @@ -21,6 +21,9 @@ See :ref:`http-api` for details on how to build your own web client. .. include:: /ext/moped.rst +.. include:: /ext/kuechenradio.rst + + JukePi ====== diff --git a/docs/ext/kuechenradio.rst b/docs/ext/kuechenradio.rst new file mode 100644 index 00000000..fb8df675 --- /dev/null +++ b/docs/ext/kuechenradio.rst @@ -0,0 +1,15 @@ +Mopidy-HTTP-Kuechenradio +========================= + +https://github.com/tkem/mopidy-http-kuechenradio + +A deliberately simple Mopidy Web client for mobile devices. Made with jQuery +Mobile by Thomas Kemmer. + +To install, run:: + + pip install Mopidy-HTTP-Kuechenradio + +.. image:: /ext/kuechenradio.png + :width: 1275 + :height: 600 diff --git a/docs/ext/web.rst b/docs/ext/web.rst index e9a2bb02..8a72c7e1 100644 --- a/docs/ext/web.rst +++ b/docs/ext/web.rst @@ -15,6 +15,9 @@ to show up here, follow the :ref:`guide on creating extensions `. .. include:: /ext/api_explorer.rst +.. include:: /ext/kuechenradio.rst + + .. include:: /ext/moped.rst From c510ac94e060422ea4af89f99d936f66b5390452 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 01:03:48 +0200 Subject: [PATCH 07/18] docs: Kuechenradio doesn't have a screenshot yet (cherry picked from commit 580e5b079fb31b1ba6df6bfd5235272939e2dfc2) --- docs/ext/kuechenradio.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/ext/kuechenradio.rst b/docs/ext/kuechenradio.rst index fb8df675..5288caeb 100644 --- a/docs/ext/kuechenradio.rst +++ b/docs/ext/kuechenradio.rst @@ -9,7 +9,3 @@ Mobile by Thomas Kemmer. To install, run:: pip install Mopidy-HTTP-Kuechenradio - -.. image:: /ext/kuechenradio.png - :width: 1275 - :height: 600 From 8cbecd66132da79dc773ef7b25584b8c489ca459 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 01:05:34 +0200 Subject: [PATCH 08/18] docs: Put screenshot between description and install instructions (cherry picked from commit 52baf639929fd5b94169c5fb179330f900d2fd7e) --- docs/ext/api_explorer.rst | 8 ++++---- docs/ext/moped.rst | 8 ++++---- docs/ext/musicbox_webclient.rst | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/ext/api_explorer.rst b/docs/ext/api_explorer.rst index 36e9dfb6..3049a647 100644 --- a/docs/ext/api_explorer.rst +++ b/docs/ext/api_explorer.rst @@ -7,10 +7,10 @@ https://github.com/dz0ny/mopidy-api-explorer Web extension for browsing the Mopidy HTTP API. -To install, run:: - - pip install Mopidy-API-Explorer - .. image:: /ext/api_explorer.png :width: 1176 :height: 713 + +To install, run:: + + pip install Mopidy-API-Explorer diff --git a/docs/ext/moped.rst b/docs/ext/moped.rst index a05d550f..573a6519 100644 --- a/docs/ext/moped.rst +++ b/docs/ext/moped.rst @@ -5,10 +5,10 @@ https://github.com/martijnboland/moped A Mopidy web client made with AngularJS by Martijn Boland. -To install, run:: - - pip install Mopidy-Moped - .. image:: /ext/moped.png :width: 720 :height: 450 + +To install, run:: + + pip install Mopidy-Moped diff --git a/docs/ext/musicbox_webclient.rst b/docs/ext/musicbox_webclient.rst index afa78685..83cc4e37 100644 --- a/docs/ext/musicbox_webclient.rst +++ b/docs/ext/musicbox_webclient.rst @@ -7,10 +7,10 @@ The first web client for Mopidy, made with jQuery Mobile by Wouter van Wijk. Also the web client used for Wouter's popular `Pi Musicbox `_ image for Raspberry Pi. -To install, run:: - - pip install Mopidy-MusicBox-Webclient - .. image:: /ext/musicbox_webclient.png :width: 1275 :height: 600 + +To install, run:: + + pip install Mopidy-MusicBox-Webclient From d408685dd477003054bfe87dfed2798d01747012 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 20 Sep 2014 01:08:04 +0200 Subject: [PATCH 09/18] docs: Remove duplicate extensions (cherry picked from commit 456faee9483e9b8407d0fd4c8dd472c4ae4e20cd) --- docs/ext/backends.rst | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/docs/ext/backends.rst b/docs/ext/backends.rst index 2b516f55..5b7c99bb 100644 --- a/docs/ext/backends.rst +++ b/docs/ext/backends.rst @@ -106,24 +106,6 @@ Extension for Mopidy-Podcast that lets you search and browse podcasts from the Apple iTunes Store. -Mopidy-Podcast-gpodder.net -========================== - -https://github.com/tkem/mopidy-podcast-gpodder - -Extension for Mopidy-Podcast that lets you search and browse podcasts from the -`gpodder.net `_ web site. - - -Mopidy-Podcast-iTunes -===================== - -https://github.com/tkem/mopidy-podcast-itunes - -Extension for Mopidy-Podcast that lets you search and browse podcasts from the -Apple iTunes Store. - - Mopidy-radio-de =============== From b0e00eeb0ff80e246d8bbf16beaff63b2ca8b15c Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 21 Sep 2014 23:24:51 +0200 Subject: [PATCH 10/18] docs: Update Mopidy-HTTP docs wrt the HTTP server-side API (cherry picked from commit 713bca384a4eebd63b2d0fbe4eabf7ffb2ad4191) --- docs/ext/http.rst | 54 ++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/docs/ext/http.rst b/docs/ext/http.rst index 0175fe1d..a006c770 100644 --- a/docs/ext/http.rst +++ b/docs/ext/http.rst @@ -23,50 +23,25 @@ When it is enabled it starts a web server at the port specified by the takes care or user authentication. You have been warned. -Using a web based Mopidy client -=============================== +Hosting web clients +=================== -Mopidy-HTTP's web server can also host any static files, for example the HTML, -CSS, JavaScript, and images needed for a web based Mopidy client. To host -static files, change the :confval:`http/static_dir` config value to point to -the root directory of your web client, for example:: +Mopidy-HTTP's web server can also host Tornado apps or any static files, for +example the HTML, CSS, JavaScript, and images needed for a web based Mopidy +client. See :ref:`http-server-api` for how to make static files or server-side +functionality from a Mopidy extension available through Mopidy's web server. - [http] - static_dir = /home/alice/dev/the-client - -If the directory includes a file named ``index.html``, it will be served on the -root of Mopidy's web server. - -If you're making a web based client and wants to do server side development as -well, you are of course free to run your own web server and just use Mopidy's -web server to host the API end points. But, for clients implemented purely in -JavaScript, letting Mopidy host the files is a simpler solution. +If you're making a web based client and wants to do server side development +using some other technology than Tornado, you are of course free to run your +own web server and just use Mopidy's web server to host the API endpoints. +But, for clients implemented purely in JavaScript, letting Mopidy host the +files is a simpler solution. See :ref:`http-api` for details on how to integrate with Mopidy over HTTP. If you're looking for a web based client for Mopidy, go check out :ref:`http-clients`. -Extending the server's functionality -==================================== - -If you wish to extend the server with additional server side functionality you -must create class that implements the :class:`mopidy.http.Router` interface and -install it in the extension registry under the ``http:router`` name. - -The default implementation of :class:`mopidy.http.Router` already supports -serving static files. If you just want to serve static files you only need to -define the class variables :attr:`mopidy.http.Router.name` and -:attr:`mopidy.http.Router.path`. For example:: - - class MyWebClient(http.Router): - name = 'mywebclient' - path = os.path.join(os.path.dirname(__file__), 'public_html') - -If you wish to extend server with custom methods you can override the method -:meth:`mopidy.http.Router.setup_routes` and define custom routes. - - Configuration ============= @@ -103,6 +78,13 @@ See :ref:`config` for general help on configuring Mopidy. Change this to have Mopidy serve e.g. files for your JavaScript client. "/mopidy" will continue to work as usual even if you change this setting. + This config value isn't deprecated yet, but you're strongly encouraged to + make Mopidy extensions which use the the :ref:`http-server-api` to host + static files on Mopidy's web server instead of using + :confval:`http/static_dir`. That way, installation of your web client will + be a lot easier for your end users, and multiple web clients can easily + share the same web server. + .. confval:: http/zeroconf Name of the HTTP service when published through Zeroconf. The variables From 00391334577614136f03b98bfda45b1d708f5326 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Sun, 21 Sep 2014 22:49:27 +0100 Subject: [PATCH 11/18] docs: typo in Mopidy-HTTP (cherry picked from commit 839108e7c56aaacebac349835448e40027abef91) --- docs/ext/http.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ext/http.rst b/docs/ext/http.rst index a006c770..54d44ce0 100644 --- a/docs/ext/http.rst +++ b/docs/ext/http.rst @@ -31,7 +31,7 @@ example the HTML, CSS, JavaScript, and images needed for a web based Mopidy client. See :ref:`http-server-api` for how to make static files or server-side functionality from a Mopidy extension available through Mopidy's web server. -If you're making a web based client and wants to do server side development +If you're making a web based client and want to do server side development using some other technology than Tornado, you are of course free to run your own web server and just use Mopidy's web server to host the API endpoints. But, for clients implemented purely in JavaScript, letting Mopidy host the From 7cf089a4adc6c3690b525fbf24f6ab17bfa9484a Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 27 Sep 2014 00:17:23 +0200 Subject: [PATCH 12/18] readme: s/Mailing/Announcement/ (cherry picked from commit b2c1b9d4db91d72552a2f3f82f730898d4da07e9) --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 46880c9d..a70eef7e 100644 --- a/README.rst +++ b/README.rst @@ -56,7 +56,7 @@ To get started with Mopidy, check out - `Development branch tarball `_ - IRC: ``#mopidy`` at `irc.freenode.net `_ -- Mailing list: `mopidy@googlegroups.com `_ +- Announcement list: `mopidy@googlegroups.com `_ - Twitter: `@mopidy `_ .. image:: https://img.shields.io/pypi/v/Mopidy.svg?style=flat From fe63e425d514c5fd157a08033d7522ec230273e3 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 11 Oct 2014 16:40:10 +0200 Subject: [PATCH 13/18] docs: Update Debian docs with 'mopidyctl' (cherry picked from commit 933cbe1dce9d596116bb20aa51ab9008fe70d0b3) --- docs/debian.rst | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/debian.rst b/docs/debian.rst index e0a4bd45..f026d4a9 100644 --- a/docs/debian.rst +++ b/docs/debian.rst @@ -63,16 +63,16 @@ from a regular Mopidy setup you'll want to know about. - The init script runs Mopidy as the ``mopidy`` user. The ``mopidy`` user will need read access to any local music you want Mopidy to play. -- To run Mopidy subcommands with the same arguments, and thus the same - configuration files, as the init script uses, you can use ``sudo service - mopidy run ``. In other words, where you'll usually run:: +- To run Mopidy subcommands with the same user and config files as the init + script uses, you can use ``sudo mopidyctl ``. In other words, + where you'll usually run:: mopidy config You should instead run the following to inspect the system service's configuration:: - sudo service mopidy run config + sudo mopidyctl config The same applies to scanning your local music collection. Where you'll normally run:: @@ -81,7 +81,12 @@ from a regular Mopidy setup you'll want to know about. You should instead run:: - sudo service mopidy run local scan + sudo mopidyctl local scan + + Previously, you used ``sudo service mopidy run `` instead of + ``mopidyctl``. This was deprecated in Debian package version 0.19.4-3 in + favor of ``mopidyctl``, which also work for systems using systemd instead of + sysvinit and traditional init scripts. - Mopidy is started, stopped, and restarted just like any other system service:: From c9b0101e76a5ea332b48df75a00edc5bfa2e002a Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 12 Oct 2014 11:40:59 +0200 Subject: [PATCH 14/18] docs: Make extensiondev example and API docs for validate_environment() match (cherry picked from commit 31c874b3eb57ac5e26ae0f72455d12c54ba7625e) --- docs/extensiondev.rst | 2 +- mopidy/ext.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index c0d36515..100e5b85 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -317,7 +317,7 @@ This is ``mopidy_soundspot/__init__.py``:: gobject.type_register(SoundspotMixer) gst.element_register( SoundspotMixer, 'soundspotmixer', gst.RANK_MARGINAL) - + # Or nothing to register e.g. command extension pass diff --git a/mopidy/ext.py b/mopidy/ext.py index 3f375a69..3333ec3f 100644 --- a/mopidy/ext.py +++ b/mopidy/ext.py @@ -52,7 +52,7 @@ class Extension(object): return schema def get_command(self): - """Command to expose to command line users running mopidy. + """Command to expose to command line users running ``mopidy``. :returns: Instance of a :class:`~mopidy.commands.Command` class. @@ -60,12 +60,13 @@ class Extension(object): pass def validate_environment(self): - """Checks if the extension can run in the current environment + """Checks if the extension can run in the current environment. - For example, this method can be used to check if all dependencies that - are needed are installed. If a problem is found, raise - :exc:`~mopidy.exceptions.ExtensionError` with a message explaining the - issue. + Dependencies described by :file:`setup.py` are checked by Mopidy, so + you should not check their presence here. + + If a problem is found, raise :exc:`~mopidy.exceptions.ExtensionError` + with a message explaining the issue. :raises: :exc:`~mopidy.exceptions.ExtensionError` :returns: :class:`None` From a13f90d9d9ab5d1606cabb24aea302fae45e5490 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 13 Oct 2014 23:14:44 +0200 Subject: [PATCH 15/18] docs: Replace /etc/mopidy/extensions.d with /usr/share/mopidy/conf.d (cherry picked from commit a1aad39c137ab92afc17332a3b91e3f60488ea17) --- docs/debian.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/debian.rst b/docs/debian.rst index f026d4a9..37d19d04 100644 --- a/docs/debian.rst +++ b/docs/debian.rst @@ -55,11 +55,18 @@ from a regular Mopidy setup you'll want to know about. You can do all your changes in this file. - Mopidy extensions installed from Debian packages will sometimes install - additional configuration files in :file:`/etc/mopidy/extensions.d/`. These + additional configuration files in :file:`/usr/share/mopidy/conf.d/`. These files just provide different defaults for the extension when run as a system - service. You can override anything from :file:`/etc/mopidy/extensions.d/` in + service. You can override anything from :file:`/usr/share/mopidy/conf.d/` in the :file:`/etc/mopidy/mopidy.conf` configuration file. + Previously, the extension's default config was installed in + :file:`/etc/mopidy/extensions.d/`. This was removed with the Debian + package mopidy 0.19.4-3. If you have modified any files in + :file:`/etc/mopidy/extensions.d/`, you should redo your modifications in + :file:`/etc/mopidy/mopidy.conf` and delete the + :etc:`/etc/mopidy/extensions.d/` directory. + - The init script runs Mopidy as the ``mopidy`` user. The ``mopidy`` user will need read access to any local music you want Mopidy to play. From aede889203216868523de462105b6715614bcc73 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 14 Oct 2014 21:09:46 +0200 Subject: [PATCH 16/18] docs: Fix typo (cherry picked from commit c7a6a2abd9a941da6accf9ffa0d03094c9fd9f6b) --- docs/debian.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/debian.rst b/docs/debian.rst index 37d19d04..f37c0673 100644 --- a/docs/debian.rst +++ b/docs/debian.rst @@ -65,7 +65,7 @@ from a regular Mopidy setup you'll want to know about. package mopidy 0.19.4-3. If you have modified any files in :file:`/etc/mopidy/extensions.d/`, you should redo your modifications in :file:`/etc/mopidy/mopidy.conf` and delete the - :etc:`/etc/mopidy/extensions.d/` directory. + :file:`/etc/mopidy/extensions.d/` directory. - The init script runs Mopidy as the ``mopidy`` user. The ``mopidy`` user will need read access to any local music you want Mopidy to play. From 88d64044dec008b075654e2c97273d92f0ef8d9b Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 22 Sep 2014 21:42:57 +0200 Subject: [PATCH 17/18] models: Hide empty lists from repr() (cherry picked from commit 305a76486d59a4fd24f335b16c80854dd0a232df) Conflicts: docs/changelog.rst --- docs/changelog.rst | 6 ++++++ mopidy/models.py | 2 ++ tests/test_models.py | 21 ++++++++------------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index ad707948..c0a1a9b8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,12 @@ Changelog This changelog is used to track all major changes to Mopidy. +v0.19.5 (UNRELEASED) +==================== + +- Models: Hide empty collections from :func:`repr()` representations. + + v0.19.4 (2014-09-01) ==================== diff --git a/mopidy/models.py b/mopidy/models.py index 42313922..83888ae5 100644 --- a/mopidy/models.py +++ b/mopidy/models.py @@ -29,6 +29,8 @@ class ImmutableObject(object): kwarg_pairs = [] for (key, value) in sorted(self.__dict__.items()): if isinstance(value, (frozenset, tuple)): + if not value: + continue value = list(value) kwarg_pairs.append('%s=%s' % (key, repr(value))) return '%(classname)s(%(kwargs)s)' % { diff --git a/tests/test_models.py b/tests/test_models.py index 43343ce7..448d6208 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -318,13 +318,12 @@ class AlbumTest(unittest.TestCase): def test_repr_without_artists(self): self.assertEquals( - "Album(artists=[], images=[], name=u'name', uri=u'uri')", + "Album(name=u'name', uri=u'uri')", repr(Album(uri='uri', name='name'))) def test_repr_with_artists(self): self.assertEquals( - "Album(artists=[Artist(name=u'foo')], images=[], name=u'name', " - "uri=u'uri')", + "Album(artists=[Artist(name=u'foo')], name=u'name', uri=u'uri')", repr(Album(uri='uri', name='name', artists=[Artist(name='foo')]))) def test_serialize_without_artists(self): @@ -551,14 +550,12 @@ class TrackTest(unittest.TestCase): def test_repr_without_artists(self): self.assertEquals( - "Track(artists=[], composers=[], name=u'name', " - "performers=[], uri=u'uri')", + "Track(name=u'name', uri=u'uri')", repr(Track(uri='uri', name='name'))) def test_repr_with_artists(self): self.assertEquals( - "Track(artists=[Artist(name=u'foo')], composers=[], name=u'name', " - "performers=[], uri=u'uri')", + "Track(artists=[Artist(name=u'foo')], name=u'name', uri=u'uri')", repr(Track(uri='uri', name='name', artists=[Artist(name='foo')]))) def test_serialize_without_artists(self): @@ -773,8 +770,7 @@ class TlTrackTest(unittest.TestCase): def test_repr(self): self.assertEquals( - "TlTrack(tlid=123, track=Track(artists=[], composers=[], " - "performers=[], uri=u'uri'))", + "TlTrack(tlid=123, track=Track(uri=u'uri'))", repr(TlTrack(tlid=123, track=Track(uri='uri')))) def test_serialize(self): @@ -903,13 +899,12 @@ class PlaylistTest(unittest.TestCase): def test_repr_without_tracks(self): self.assertEquals( - "Playlist(name=u'name', tracks=[], uri=u'uri')", + "Playlist(name=u'name', uri=u'uri')", repr(Playlist(uri='uri', name='name'))) def test_repr_with_tracks(self): self.assertEquals( - "Playlist(name=u'name', tracks=[Track(artists=[], composers=[], " - "name=u'foo', performers=[])], uri=u'uri')", + "Playlist(name=u'name', tracks=[Track(name=u'foo')], uri=u'uri')", repr(Playlist(uri='uri', name='name', tracks=[Track(name='foo')]))) def test_serialize_without_tracks(self): @@ -1036,7 +1031,7 @@ class SearchResultTest(unittest.TestCase): def test_repr_without_results(self): self.assertEquals( - "SearchResult(albums=[], artists=[], tracks=[], uri=u'uri')", + "SearchResult(uri=u'uri')", repr(SearchResult(uri='uri'))) def test_serialize_without_results(self): From a4b17a9aa81afcb7041c92544ad55a6cfed60ef2 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 22 Sep 2014 21:48:26 +0200 Subject: [PATCH 18/18] models: Fix equality for fields set to the default Fixes #837 (cherry picked from commit bdd1fb983b3abbbb604686e63647a8aaaa5d97a0) --- docs/changelog.rst | 6 ++++++ mopidy/models.py | 8 ++++---- tests/test_models.py | 22 ++++++++++++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c0a1a9b8..bde9759b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,12 @@ v0.19.5 (UNRELEASED) - Models: Hide empty collections from :func:`repr()` representations. +- Field values are no longer stored on the model instance when the value + matches the default value for the field. This makes two models equal when + they have a field which in one case is implicitly set to the default value + and in the other case explicitly set to the default value, but with otherwise + equal fields. (Fixes: :issue:`837`) + v0.19.4 (2014-09-01) ==================== diff --git a/mopidy/models.py b/mopidy/models.py index 83888ae5..510cb56a 100644 --- a/mopidy/models.py +++ b/mopidy/models.py @@ -18,6 +18,8 @@ class ImmutableObject(object): raise TypeError( '__init__() got an unexpected keyword argument "%s"' % key) + if value == getattr(self, key): + continue # Don't explicitly set default values self.__dict__[key] = value def __setattr__(self, name, value): @@ -72,13 +74,11 @@ class ImmutableObject(object): for key in self.__dict__.keys(): public_key = key.lstrip('_') value = values.pop(public_key, self.__dict__[key]) - if value is not None: - data[public_key] = value + data[public_key] = value for key in values.keys(): if hasattr(self, key): value = values.pop(key) - if value is not None: - data[key] = value + data[key] = value if values: raise TypeError( 'copy() got an unexpected keyword argument "%s"' % key) diff --git a/tests/test_models.py b/tests/test_models.py index 448d6208..09610b99 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -171,8 +171,8 @@ class ArtistTest(unittest.TestCase): def test_serialize_falsy_values(self): self.assertDictEqual( - {'__model__': 'Artist', 'uri': '', 'name': None}, - Artist(uri='', name=None).serialize()) + {'__model__': 'Artist', 'uri': '', 'name': ''}, + Artist(uri='', name='').serialize()) def test_to_json_and_back(self): artist1 = Artist(uri='uri', name='name') @@ -735,6 +735,24 @@ class TrackTest(unittest.TestCase): self.assertNotEqual(track1, track2) self.assertNotEqual(hash(track1), hash(track2)) + def test_ignores_values_with_default_value_none(self): + track1 = Track(name='name1') + track2 = Track(name='name1', album=None) + self.assertEqual(track1, track2) + self.assertEqual(hash(track1), hash(track2)) + + def test_ignores_values_with_default_value_zero(self): + track1 = Track(name='name1') + track2 = Track(name='name1', track_no=0) + self.assertEqual(track1, track2) + self.assertEqual(hash(track1), hash(track2)) + + def test_copy_can_reset_to_default_value(self): + track1 = Track(name='name1') + track2 = Track(name='name1', album=Album()).copy(album=None) + self.assertEqual(track1, track2) + self.assertEqual(hash(track1), hash(track2)) + class TlTrackTest(unittest.TestCase): def test_tlid(self):