[SCM] morituri/master: work without network

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:10:10 UTC 2014


The following commit has been merged in the master branch:
commit 120d1b239f7204bd8305a284e0fbcb11f83fe4b4
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sun Aug 4 18:11:13 2013 +0200

    work without network

diff --git a/morituri/common/program.py b/morituri/common/program.py
index 4bdced7..a65b9c0 100644
--- a/morituri/common/program.py
+++ b/morituri/common/program.py
@@ -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)
diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py
index c2c1a94..1689ae0 100644
--- a/morituri/rip/cd.py
+++ b/morituri/rip/cd.py
@@ -23,6 +23,8 @@
 import os
 import math
 import glob
+import urllib2
+import socket
 
 import gobject
 gobject.threads_init()
@@ -97,8 +99,9 @@ class _CD(logcommand.LogCommand):
                 self.stdout.write('FreeDB identifies disc as %s\n' % cddbmd)
 
             # also used by rip cd info
-            if not getattr(self.options, 'unknown', False) and self.eject:
-                self.program.ejectDevice(self.device)
+            if not getattr(self.options, 'unknown', False):
+                if self.eject:
+                    self.program.ejectDevice(self.device)
                 return -1
 
         # now, read the complete index table, which is slower
@@ -478,7 +481,18 @@ Install pycdio and run 'rip offset find' to detect your drive's offset.
         self.stdout.write("AccurateRip URL %s\n" % url)
 
         accucache = accurip.AccuCache()
-        responses = accucache.retrieve(url)
+        try:
+            responses = accucache.retrieve(url)
+        except urllib2.URLError, e:
+            if isinstance(e.args[0], socket.gaierror):
+                if e.args[0].errno == -2:
+                    self.stdout.write("Warning: network error: %r\n" % (
+                        e.args[0], ))
+                    responses = None
+                else:
+                    raise
+            else:
+                raise
 
         if not responses:
             self.stdout.write('Album not found in AccurateRip database\n')

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list