]> kaliko git repositories - python-musicpd.git/blobdiff - mpd.py
README.txt: give an example that actually works
[python-musicpd.git] / mpd.py
diff --git a/mpd.py b/mpd.py
index 2875f95ced8c42c3511ce9d60c7868692e734755..315c26210a6877bd31fe8af25055a0342f093651 100644 (file)
--- a/mpd.py
+++ b/mpd.py
@@ -1,5 +1,5 @@
 # Python MPD client library
-# Copyright (C) 2008  J. Alexander Treuman <jat@spatialrift.net>
+# Copyright (C) 2008-2010  J. Alexander Treuman <jat@spatialrift.net>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -174,14 +174,17 @@ class MPDClient(object):
             raise PendingCommandError("Cannot execute %s with "
                                       "pending commands" % command)
         retval = self._commands[command]
-        if self._command_list is not None and not callable(retval):
-            raise CommandListError("%s not allowed in command list" % command)
-        self._write_command(command, args)
-        if self._command_list is None:
+        if self._command_list is not None:
+            if not callable(retval):
+                raise CommandListError("%s not allowed in command list" %
+                                        command)
+            self._write_command(command, args)
+            self._command_list.append(retval)
+        else:
+            self._write_command(command, args)
             if callable(retval):
                 return retval()
             return retval
-        self._command_list.append(retval)
 
     def _write_line(self, line):
         self._wfile.write("%s\n" % line)
@@ -386,6 +389,11 @@ class MPDClient(object):
         self._sock.close()
         self._reset()
 
+    def fileno(self):
+        if not self._sock:
+            raise ConnectionError("Not connected")
+        return self._sock.fileno()
+
     def command_list_ok_begin(self):
         if self._command_list is not None:
             raise CommandListError("Already in command list")