work without network

This commit is contained in:
Thomas Vander Stichele
2013-08-04 18:11:13 +02:00
parent df0daefa27
commit 120d1b239f
2 changed files with 33 additions and 7 deletions

View File

@@ -33,6 +33,7 @@ from morituri.program import cdrdao, cdparanoia
from morituri.image import image
from morituri.extern.task import task, gstreamer
from morituri.extern.musicbrainzngs import musicbrainz
# FIXME: should Program have a runner ?
@@ -297,10 +298,18 @@ class Program(log.Loggable):
"""
# FIXME: convert to nonblocking?
import CDDB
code, md = CDDB.query(cddbdiscid)
self.debug('CDDB query result: %r, %r', code, md)
if code == 200:
return md['title']
try:
code, md = CDDB.query(cddbdiscid)
self.debug('CDDB query result: %r, %r', code, md)
if code == 200:
return md['title']
except IOError, e:
# FIXME: for some reason errno is a str ?
if e.errno == 'socket error':
self._stdout.write("Warning: network error: %r\n" % (e, ))
else:
raise
return None
@@ -325,6 +334,9 @@ class Program(log.Loggable):
record=self._record)
except mbngs.NotFoundException, e:
break
except musicbrainz.NetworkError, e:
self._stdout.write("Warning: network error: %r\n" % (e, ))
break
except mbngs.MusicBrainzException, e:
self._stdout.write("Warning: %r\n" % (e, ))
time.sleep(5)