summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nephilim/mpclient.py5
-rw-r--r--nephilim/mpd.py8
2 files changed, 9 insertions, 4 deletions
diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py
index 9e287d7..4e9ce34 100644
--- a/nephilim/mpclient.py
+++ b/nephilim/mpclient.py
@@ -84,9 +84,8 @@ class MPClient(QtCore.QObject):
def disconnect_mpd(self):
"""Disconnect from MPD."""
self.logger.info('Disconnecting from MPD...')
- if not self._client:
- self.logger.warning('Attempted to disconnect when not connected.')
- self._client.disconnect_mpd()
+ if self._client:
+ self._client.disconnect_mpd()
def password(self, password):
"""Use the password to authenticate with MPD."""
diff --git a/nephilim/mpd.py b/nephilim/mpd.py
index 97aa54f..bcdf3ac 100644
--- a/nephilim/mpd.py
+++ b/nephilim/mpd.py
@@ -144,7 +144,13 @@ class MPDClient(QtCore.QObject):
def _docommand(self, command, args, retval):
if self._commandlist is not None and not callable(retval):
raise CommandListError("%s not allowed in command list" % command)
- self._writecommand(command, args)
+ try:
+ self._writecommand(command, args)
+ except socket.error, e:
+ self.logger.error('Error sending command: %s.'%e)
+ self.disconnect_mpd()
+ return None
+
if self._commandlist is None:
if callable(retval):
return retval()