From c752f36a4bb75fef3ed29325dd3911f810ac1917 Mon Sep 17 00:00:00 2001 From: "adrian.sampson" Date: Fri, 3 Apr 2009 17:57:50 +0000 Subject: [PATCH] added persistent errors and clearerror --HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%40170 --- beets/player/bpd.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/beets/player/bpd.py b/beets/player/bpd.py index ba906a002..ac89dfecf 100755 --- a/beets/player/bpd.py +++ b/beets/player/bpd.py @@ -45,7 +45,7 @@ VOLUME_MIN = 0 VOLUME_MAX = 100 SAFE_COMMANDS = ( - # Commands that should be available when unauthenticated. + # Commands that are available when unauthenticated. 'close', 'commands', 'notcommands', 'password', 'ping', ) @@ -191,6 +191,7 @@ class BaseServer(object): self.playlist_version = 0 self.current_index = -1 self.paused = False + self.error = None def run(self): """Block and start listening for connections from clients. An @@ -302,8 +303,18 @@ class BaseServer(object): current_id = self._item_id(self.playlist[self.current_index]) yield 'song: ' + str(self.current_index) yield 'songid: ' + str(current_id) + + if self.error: + yield 'error: ' + self.error - #fixme Still missing: time, bitrate, audio, updating_db, error + #fixme Still missing: time, bitrate, audio, updating_db + + def cmd_clearerror(self, conn): + """Removes the persistent error state of the server. This + error is set when a problem arises not in response to a + command (for instance, when playing a file). + """ + self.error = None def cmd_random(self, conn, state): """Set or unset random (shuffle) mode."""