From c632ef7e3a89add73854aef0ae72d7b0d2d4b16c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 4 Sep 2009 14:39:08 +0200 Subject: Lyrics: decrease priority of an error message. also add error handling. --- nephilim/common.py | 6 ++++++ nephilim/plugins/Lyrics.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nephilim/common.py b/nephilim/common.py index 2663fa6..a04cc42 100644 --- a/nephilim/common.py +++ b/nephilim/common.py @@ -114,6 +114,7 @@ class MetadataFetcher(QtCore.QObject): self.logger.info('Searching %s: %s.'%(self. name, url)) self.rep = self.nam.get(QtNetwork.QNetworkRequest(url)) + self.rep.error.connect(self.handle_error) def finish(self, metadata = None): """A private convenience function to clean up and emit finished(). @@ -123,6 +124,11 @@ class MetadataFetcher(QtCore.QObject): self.finished.emit(self.song, metadata) self.song = None + def handle_error(self): + """Print the error and abort.""" + self.logger.error(self.rep.errorString()) + self.abort() + #### public #### def fetch(self, song): """Reimplement this in subclasses.""" diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py index 2bd3ea4..fe5516e 100644 --- a/nephilim/plugins/Lyrics.py +++ b/nephilim/plugins/Lyrics.py @@ -162,7 +162,7 @@ class Lyrics(Plugin): artist = xml.readElementText() xml.clear() if not artist: - self.logger.error('Didn\'t find artist in %s artist search results.'%self.name) + self.logger.info('Didn\'t find artist in %s artist search results.'%self.name) return self.finish() url = QtCore.QUrl('http://lyricwiki.org/api.php') @@ -170,6 +170,7 @@ class Lyrics(Plugin): ('song', self.song['title']), ('fmt', 'xml')]) self.rep = self.nam.get(QtNetwork.QNetworkRequest(url)) self.rep.finished.connect(self.__handle_search_res) + self.rep.error.connect(self.handle_error) def __handle_search_res(self): url = None @@ -190,7 +191,7 @@ class Lyrics(Plugin): self.logger.error('Error parsing seach results: %s'%xml.errorString()) if not url: - self.logger.error('Didn\'t find the URL in Lyricwiki search results.') + self.logger.warning('Didn\'t find the URL in Lyricwiki search results.') return self.finish() self.logger.info('Found Lyricwiki song URL: %s.'%url) @@ -200,6 +201,7 @@ class Lyrics(Plugin): req = QtNetwork.QNetworkRequest(url) self.rep = self.nam.get(req) self.rep.finished.connect(self.__handle_lyrics) + self.rep.error.connect(self.handle_error) def __handle_lyrics(self): lyrics = '' @@ -250,6 +252,7 @@ class Lyrics(Plugin): self.rep = self.nam.get(QtNetwork.QNetworkRequest(url)) self.rep.finished.connect(self.__handle_lyrics) + self.rep.error.connect(self.handle_error) def __handle_lyrics(self): lyrics = '' -- cgit v1.2.3