J. Alexander Treuman [Thu, 3 Apr 2008 04:23:36 +0000 (00:23 -0400)]
mpd.py: catch all exceptions raised by _hello()
I normally consider it bad form to catch all exceptions, since it can
result in lost KeyboardInterrupts. But in this case we re-raise the
exception after cleaning up, so it's ok.
While _hello() itself only raises socket.error or an MPDError subclass, a
KeyboardInterrupt would previously go uncaught. Since the connection was
never cleaned up, it could be left in an unusable state. So just
disconnect on all exceptions instead.
J. Alexander Treuman [Sun, 23 Mar 2008 20:47:06 +0000 (16:47 -0400)]
mpd.py: loop over addresses returned by getaddrinfo to connect to
This allows us to support IPv6 and multi-homed hostnames. getaddrinfo is
called with the same flags as libmpdclient uses, making address resolution
consistent between the two.
J. Alexander Treuman [Sun, 23 Mar 2008 19:50:48 +0000 (15:50 -0400)]
mpd.py: raise ConnectionError when trying to use an unconnected socket
ConnectionError will now be raised when trying to read from/write to a
socket before calling connect() or after calling disconnect(). In the past
it would try to complete the operation on the unconnected socket, resulting
in a socket.error exception.
J. Alexander Treuman [Sat, 1 Mar 2008 20:03:47 +0000 (15:03 -0500)]
mpd.py: making _getitem return None if no item is returned
update and addid should normally always return a single item, so previously
an exception was raised if we got nothing. However, when used in a
command_list, only the *last* call to update will return an item. So
return None instead of raising an exception if we get nothing.
J. Alexander Treuman [Mon, 25 Feb 2008 00:43:53 +0000 (19:43 -0500)]
remove argument checking/parsing TODO item
mpd already does a much better job of validating arguments than we ever
could, so no point in us doing it too. Parsing arguments is also rather
pointless, as all arguments are coerced to strings before escaping anyway.