summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-10-08 08:10:37 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-10-08 08:10:37 +0200
commitdaf59e2a7199181a689ac5c51bd360a03563f41b (patch)
tree93c2be1a4afc3efeb9e7aba5a138ca1764e78faa
parent22cd65bd2f0594fbb740b1039e664a0712831163 (diff)
mpd: catch errors when writing command.
-rw-r--r--nephilim/mpd.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/nephilim/mpd.py b/nephilim/mpd.py
index bcdf3ac..560a225 100644
--- a/nephilim/mpd.py
+++ b/nephilim/mpd.py
@@ -157,15 +157,16 @@ class MPDClient(QtCore.QObject):
return retval
self._commandlist.append(retval)
- def _writeline(self, line):
- self._wfile.write("%s\n" % line)
- self._wfile.flush()
-
def _writecommand(self, command, args=[]):
parts = [command]
for arg in args:
parts.append('"%s"' % escape(str(arg)))
- self._writeline(" ".join(parts))
+ try:
+ self._wfile.write(' '.join(parts).encode('utf-8') + '\n')
+ self._wfile.flush()
+ except socket.error, e:
+ self.logger.error('Error sending command: %s.'%e)
+ self.disconnect_mpd()
def _readline(self):
line = self._rfile.readline()