[Pkg-mpd-commits] [python-mpd] 109/262: Imported Upstream version 0.4.0

Simon McVittie smcv at debian.org
Sun May 22 18:16:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch upstream
in repository python-mpd.

commit 0426975e890591e94ec9975f676e8d58eaac9a91
Author: kaliko <efrim at azylum.org>
Date:   Sun Mar 18 22:58:44 2012 +0100

    Imported Upstream version 0.4.0
---
 CHANGES.txt |  13 +++++-
 README.md   | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.txt  |  93 -----------------------------------------
 mpd.py      |  13 +++---
 setup.py    |  26 ++++++------
 test.py     |   8 +++-
 6 files changed, 173 insertions(+), 115 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index e9dac67..adb8f30 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,17 @@
-python-mpd Changes List
+python-mpd2 Changes List
 =======================
 
+Changes in 0.4.0
+----------------
+
+* python3 support (python2.6 is minimum python version required)
+* support for the upcoming client-to-client protocol
+* adding new commands of mpd (seekcur, prior, priorid)
+* methods are explicit declared now, so they are shown in ipython
+* add unit tests
+* documented API to add new commands (see Future Compatible)
+
+
 Changes in 0.3.0
 ----------------
 
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..406f82e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,135 @@
+python-mpd2
+==========
+
+Difference to python-mpd
+-------------------------
+
+python-mpd2 is a fork of the python-mpd. It is backward compatible to python-mpd, so it could act as drop-in replacement.
+Current features list:
+
+ - python3 support (python2.6 is minimum python version required)
+ - support for the upcoming client-to-client protocol
+ - adding new commands of mpd (seekcur, prior, priorid)
+ - methods are explicit declared now, so they are shown in ipython
+ - add unit tests
+ - documented API to add new commands (see Future Compatible)
+
+I attempted to merge my changes into the original project, but never get a reponse.
+If you like this module, you could try contact the original author <jat at spatialrift.net> or join the discussion on the [issue tracker](http://jatreuman.indefero.net/p/python-mpd/issues/7/)
+
+Getting the latest source code
+------------------------------
+
+If you would instead like to use the latest source code, you can grab a copy
+of the development version from git by running the command:
+
+    $ git clone git://github.com/Mic92/python-mpd2.git
+
+
+Installing from source
+----------------------
+
+To install python-mpd from source, simply run the command:
+
+    $ python setup.py install
+
+You can use the *--help* switch to *setup.py* for a complete list of commands
+and their options.  See the [Installing Python Modules](http://docs.python.org/inst/inst.html) document for more details.
+
+
+Using packages
+--------------
+Until the python community adapt this package, here are some ready to use packages to test your applications:
+
+###debian:
+
+just add this line to your */etc/apt/sources.list*:
+
+    deb http://sima.azylum.org/debian unstable main
+
+Import the gpg key as root
+
+    $ wget -O - http://sima.azylum.org/sima.gpg | apt-key add -
+
+Key fingerprint :
+
+2255 310A D1A2 48A0 7B59  7638 065F E539 32DC 551D
+
+Controls with *apt-key finger*.
+
+Then simply update/install *python-mpd2* with apt or aptitude:
+
+###archlinux
+
+install [python-mpd-git](https://aur.archlinux.org/packages.php?ID=21531) from AUR
+
+Packages for other distributions are welcome!
+
+
+Using the client library
+------------------------
+
+The client library can be used as follows:
+
+    client = mpd.MPDClient()           # create client object
+    client.connect("localhost", 6600)  # connect to localhost:6600
+    print(client.mpd_version)          # print the mpd version
+    print(client.find("any", "house")) # print result of the command "find any house"
+    client.close()                     # send the close command
+    client.disconnect()                # disconnect from the server
+
+A list of supported commands, their arguments (as MPD currently understands
+them), and the functions used to parse their responses can be found in
+*doc/commands.txt*.  See the [MPD protocol documentation](http://www.musicpd.org/doc/protocol/) for more details.
+
+Command lists are also supported using *command_list_ok_begin()* and
+*command_list_end()*:
+
+    client.command_list_ok_begin()       # start a command list
+    client.update()                      # insert the update command into the list
+    client.status()                      # insert the status command into the list
+    results = client.command_list_end()  # results will be a list with the results
+
+Commands may also return iterators instead of lists if *iterate* is set to
+*True*:
+
+    client.iterate = True
+    for song in client.playlistinfo():
+        print song["file"]
+
+Each command have a *send_* and a *fetch_* variant, which allows to send a
+mpd command and the fetch the result later. This is useful for the idle
+command:
+
+    client.send_idle()
+    # do something else ...
+    events = client.fetch_idle()
+
+Some more complex usage example can be found [here](http://jatreuman.indefero.net/p/python-mpd/doc/)
+
+Future Compatible
+-----------------
+
+New commands or special handling of commands can be easily implemented.
+Use *add_command()* or *remove_command()* to modify the commands of the
+*MPDClient* class and all its instances.
+
+
+    def fetch_cover(client):
+        """"Take a MPDClient instance as its arguments and return mimetype and image"""
+        # this command may come in the future.
+        pass
+    self.client.add_command("get_cover", fetch_cover)
+    # remove the command, because it doesn't exist already.
+    self.client.remove_command("get_cover")
+
+Contacting the author
+---------------------
+
+Just connect me (Mic92) on github or via email (jthalheim at gmail.com).
+
+Usally I hang around on jabber: sonata at conference.codingteam.net
+
+You can contact the original author by emailing J. Alexander Treuman <jat at spatialrift.net>.
+
+He can also be found idling in #mpd on irc.freenode.net as jat.
diff --git a/README.txt b/README.txt
deleted file mode 100644
index c8b68df..0000000
--- a/README.txt
+++ /dev/null
@@ -1,93 +0,0 @@
-python-mpd
-==========
-
-Getting python-mpd
-------------------
-
-The latest release of python-mpd can be found at
-http://pypi.python.org/pypi/python-mpd/.
-
-
-Getting the latest source code
-------------------------------
-
-If you would instead like to use the latest source code, you can grab a copy
-of the development version from git by running the command::
-
-  git clone git://jatreuman.indefero.net/jatreuman/python-mpd.git
-
-
-Installing from source
-----------------------
-
-To install python-mpd from source, simply run the command::
-
-  python setup.py install
-
-You can use the ``--help`` switch to ``setup.py`` for a complete list of commands
-and their options.  See the `Installing Python Modules
-<http://docs.python.org/inst/inst.html>`_ document for more details.
-
-
-Using the client library
-------------------------
-
-The client library can be used as follows::
-
-    client = mpd.MPDClient()           # create client object
-    client.connect("localhost", 6600)  # connect to localhost:6600
-    print(client.mpd_version)          # print the mpd version
-    print(client.find("any", "house")) # print result of the command "find any house"
-    client.close()                     # send the close command
-    client.disconnect()                # disconnect from the server
-
-A list of supported commands, their arguments (as MPD currently understands
-them), and the functions used to parse their responses can be found in
-`doc/commands.txt`.  See the `MPD protocol documentation
-<http://www.musicpd.org/doc/protocol/>`_ for more details.
-
-Command lists are also supported using ``command_list_ok_begin()`` and
-``command_list_end()``::
-
-    client.command_list_ok_begin()       # start a command list
-    client.update()                      # insert the update command into the list
-    client.status()                      # insert the status command into the list
-    results = client.command_list_end()  # results will be a list with the results
-
-Commands may also return iterators instead of lists if ``iterate`` is set to
-``True``::
-
-    client.iterate = True
-    for song in client.playlistinfo():
-        print song["file"]
-
-Each command have a ``send_`` and a ``fetch_`` variant, which allows to send a
-mpd command and the fetch the result later. This is useful for the idle
-command::
-
-    client.send_idle()
-    # do something else ...
-    events = client.fetch_idle()
-
-Future Compatible
------------------
-
-New commands or special handling of commands can be easily implemented.
-Use ``add_command()`` or ``remove_command()`` to modify the commands of the
-``MPDClient`` class and all its instances.
-
-::
-
-    def fetch_cover(client):
-        """"Take a MPDClient instance as its arguments and return mimetype and image"""
-        # this command may come in the future.
-        pass
-    self.client.add_command("get_cover", fetch_cover)
-    # remove the command, because it doesn't exist already.
-    self.client.remove_command("get_cover")
-
-Contacting the author
----------------------
-
-You can contact the author by emailing J. Alexander Treuman jat at spatialrift.net.
-He can also be found idling in #mpd on irc.freenode.net as jat.
diff --git a/mpd.py b/mpd.py
index 6995bb2..9a29c61 100644
--- a/mpd.py
+++ b/mpd.py
@@ -1,18 +1,19 @@
-# python-mpd: Python MPD client library
+# python-mpd2: Python MPD client library
 # Copyright (C) 2008-2010  J. Alexander Treuman <jat at spatialrift.net>
+# Copyright (C) 2012  J. Thalheim <jthalheim at gmail.com>
 #
-# python-mpd is free software: you can redistribute it and/or modify
+# python-mpd2 is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
-# python-mpd is distributed in the hope that it will be useful,
+# python-mpd2 is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public License
-# along with python-mpd.  If not, see <http://www.gnu.org/licenses/>.
+# along with python-mpd2.  If not, see <http://www.gnu.org/licenses/>.
 
 import socket
 from collections import Callable
@@ -394,11 +395,11 @@ class MPDClient():
                 err = e
                 if sock is not None:
                     sock.close()
-        if err is not None:
-            raise err
         else:
             raise ConnectionError("getaddrinfo returns an empty list")
 
+        raise err
+
     def connect(self, host, port):
         if self._sock is not None:
             raise ConnectionError("Already connected")
diff --git a/setup.py b/setup.py
index f5f23dc..c8e5b8d 100644
--- a/setup.py
+++ b/setup.py
@@ -20,31 +20,29 @@ CLASSIFIERS = [
 
 LICENSE = """\
 Copyright (C) 2008-2010  J. Alexander Treuman <jat at spatialrift.net>
+Copyright (C) 2012  J. Thalheim <jat at spatialrift.net>
 
-python-mpd is free software: you can redistribute it and/or modify
+python-mpd2 is free software: you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
-python-mpd is distributed in the hope that it will be useful,
+python-mpd2 is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with python-mpd.  If not, see <http://www.gnu.org/licenses/>.\
+GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License
+along with python-mpd2.  If not, see <http://www.gnu.org/licenses/>.\
 """
 
-
 setup(
-    name="python-mpd",
-    version="0.3.0",
-    description="Python MPD client library",
+    name="python-mpd2",
+    version="0.4.0",
+    description="A Python MPD client library",
     long_description=DESCRIPTION,
-    author="J. Alexander Treuman",
-    author_email="jat at spatialrift.net",
-    url="http://jatreuman.indefero.net/p/python-mpd/",
-    download_url="http://pypi.python.org/pypi/python-mpd/",
+    author="J. Thalheim",
+    author_email="jthalheim at gmail.com",
+    url="https://github.com/Mic92/python-mpd2",
+    download_url="https://github.com/Mic92/python-mpd2",
     py_modules=["mpd"],
     classifiers=CLASSIFIERS,
     #license=LICENSE,
diff --git a/test.py b/test.py
index 1434e09..5ff9ee5 100755
--- a/test.py
+++ b/test.py
@@ -32,7 +32,7 @@ class TestMPDClient(unittest.TestCase):
         try:
             self.client.connect(MPD_HOST, MPD_PORT)
             self.idleclient.connect(MPD_HOST, MPD_PORT)
-        except SocketError as e:
+        except (ConnectionError, SocketError) as e:
             raise Exception("Can't connect mpd! Start it or check the configuration: %s" % e)
         if MPD_PASSW != None:
             try:
@@ -128,5 +128,11 @@ class TestMPDClient(unittest.TestCase):
         channels = self.client.channels()
         self.assertNotIn("monty", channels)
 
+    def test_connection_error(self):
+        client2 = MPDClient()
+        with self.assertRaises(ConnectionError) as cm:
+            # should never return getaddrinfo
+            client2.connect("255.255.255.255", 6600)
+
 if __name__ == '__main__':
     unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git



More information about the Pkg-mpd-commits mailing list