Update Last.fm frontend to catch new exceptions thrown by pylast 0.5.7

This commit is contained in:
Stein Magnus Jodal 2011-01-21 23:55:55 +01:00
parent 3f49cda5d2
commit f28a62b4a2
3 changed files with 12 additions and 27 deletions

View File

@ -33,7 +33,7 @@ to this problem.
the latest pyspotify from the Mopidy developers. Follow the instructions at
:doc:`/installation/libspotify/`.
- If you use the Last.fm frontend, you need to upgrade to pylast 0.5. Run
- If you use the Last.fm frontend, you need to upgrade to pylast 0.5.7. Run
``sudp pip install --upgrade pylast`` or install Mopidy from APT.

View File

@ -1,9 +1,6 @@
from httplib import HTTPException
import logging
import multiprocessing
import socket
import time
from xml.parsers.expat import ExpatError
try:
import pylast
@ -31,7 +28,7 @@ class LastfmFrontend(BaseFrontend):
**Dependencies:**
- `pylast <http://code.google.com/p/pylast/>`_ >= 0.5
- `pylast <http://code.google.com/p/pylast/>`_ >= 0.5.7
**Settings:**
@ -56,18 +53,6 @@ class LastfmFrontend(BaseFrontend):
class LastfmFrontendThread(BaseThread):
# Whenever we call pylast, we catch the following non-pylast exceptions, as
# they are not caught and wrapped by pylast.
#
# socket.error:
# Not reported upstream.
# UnicodeDecodeError:
# http://code.google.com/p/pylast/issues/detail?id=55
# xml.parsers.expat.ExpatError:
# http://code.google.com/p/pylast/issues/detail?id=58
# httplib.HTTPException:
# Not reported upstream.
def __init__(self, core_queue, connection):
super(LastfmFrontendThread, self).__init__(core_queue)
self.name = u'LastfmFrontendThread'
@ -93,9 +78,9 @@ class LastfmFrontendThread(BaseThread):
except SettingsError as e:
logger.info(u'Last.fm scrobbler not started')
logger.debug(u'Last.fm settings error: %s', e)
except (pylast.WSError, socket.error, UnicodeDecodeError, ExpatError,
HTTPException) as e:
logger.error(u'Last.fm connection error: %s', e)
except (pylast.NetworkError, pylast.MalformedResponseError,
pylast.WSError) as e:
logger.error(u'Error during Last.fm setup: %s', e)
def process_message(self, message):
if message['command'] == 'started_playing':
@ -118,9 +103,9 @@ class LastfmFrontendThread(BaseThread):
duration=str(duration),
track_number=str(track.track_no),
mbid=(track.musicbrainz_id or ''))
except (pylast.ScrobblingError, pylast.WSError, socket.error,
UnicodeDecodeError, ExpatError, HTTPException) as e:
logger.warning(u'Last.fm now playing error: %s', e)
except (pylast.ScrobblingError, pylast.NetworkError,
pylast.MalformedResponseError, pylast.WSError) as e:
logger.warning(u'Error submitting playing track to Last.fm: %s', e)
def stopped_playing(self, track, stop_position):
artists = ', '.join([a.name for a in track.artists])
@ -145,6 +130,6 @@ class LastfmFrontendThread(BaseThread):
track_number=str(track.track_no),
duration=str(duration),
mbid=(track.musicbrainz_id or ''))
except (pylast.ScrobblingError, pylast.WSError, socket.error,
UnicodeDecodeError, ExpatError, HTTPException) as e:
logger.warning(u'Last.fm scrobbling error: %s', e)
except (pylast.ScrobblingError, pylast.NetworkError,
pylast.MalformedResponseError, pylast.WSError) as e:
logger.warning(u'Error submitting played track to Last.fm: %s', e)

View File

@ -1 +1 @@
pylast >= 0.5
pylast >= 0.5.7