[SCM] morituri/master: * morituri/common/drive.py: Really make pycdio and cdio optional. * morituri/rip/drive.py: * morituri/rip/offset.py: Use drive.getAllDevicePaths()

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


The following commit has been merged in the master branch:
commit 10375235dab481dcfae9208248a1d8cdc5c4bea6
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Tue Jun 16 19:27:18 2009 +0000

    	* morituri/common/drive.py:
    	  Really make pycdio and cdio optional.
    	* morituri/rip/drive.py:
    	* morituri/rip/offset.py:
    	  Use drive.getAllDevicePaths()

diff --git a/ChangeLog b/ChangeLog
index f2d08a1..47a2421 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-16  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* morituri/common/drive.py:
+	  Really make pycdio and cdio optional.
+	* morituri/rip/drive.py:
+	* morituri/rip/offset.py:
+	  Use drive.getAllDevicePaths()
+
 2009-06-15  Thomas Vander Stichele  <thomas at apestaart dot org>
 
 	* morituri/result/result.py:
diff --git a/morituri/common/drive.py b/morituri/common/drive.py
index 26f1988..55ec837 100644
--- a/morituri/common/drive.py
+++ b/morituri/common/drive.py
@@ -20,8 +20,31 @@
 # You should have received a copy of the GNU General Public License
 # along with morituri.  If not, see <http://www.gnu.org/licenses/>.
 
-import pycdio
-import cdio
+import os
+
+from morituri.common import log
 
 def getAllDevicePaths():
-    return cdio.get_devices_with_cap(pycdio.FS_AUDIO, False)
+    try:
+        return _getAllDevicePathsPyCdio()
+    except ImportError:
+        log.info('drive', 'Cannot import pycdio')
+        return _getAllDevicePathsStatic()
+        
+def _getAllDevicePathsPyCdio():
+    import pycdio
+    import cdio
+
+    # using FS_AUDIO here only makes it list the drive when an audio cd
+    # is inserted
+    return cdio.get_devices_with_cap(pycdio.FS_MATCH_ALL, False)
+
+def _getAllDevicePathsStatic():
+    ret = []
+
+    for c in ['/dev/cdrom', '/dev/cdrecorder']:
+        if os.path.exists(c):
+            ret.append(c)
+
+    return ret
+
diff --git a/morituri/rip/drive.py b/morituri/rip/drive.py
index 6f45626..f36adc3 100644
--- a/morituri/rip/drive.py
+++ b/morituri/rip/drive.py
@@ -28,27 +28,15 @@ class List(logcommand.LogCommand):
     summary = "list drives"
 
     def do(self, args):
-        try:
-            import pycdio
-            import cdio
-        except ImportError:
-            self.info('pycdio not installed, cannot list drives')
-            found = False
-            for c in ['/dev/cdrom', '/dev/cdrecorder']:
-                if os.path.exists(c):
-                    print "drive: %s", c
-                    found = True
+        paths = drive.getAllDevicePaths()
 
-            if not found:
-                print 'No drives found.'
-                print 'Create /dev/cdrom if you have a CD drive, '
-                print 'or install pycdio for better detection.'
+        if not paths:
+            print 'No drives found.'
+            print 'Create /dev/cdrom if you have a CD drive, '
+            print 'or install pycdio for better detection.'
 
             return
 
-        # using FS_AUDIO here only makes it list the drive when an audio cd
-        # is inserted
-        paths = cdio.get_devices_with_cap(pycdio.FS_MATCH_ALL, False)
         for path in paths:
             device = cdio.Device(path)
             ok, vendor, model, release = device.get_hwinfo()
diff --git a/morituri/rip/offset.py b/morituri/rip/offset.py
index ce135d0..2139eca 100644
--- a/morituri/rip/offset.py
+++ b/morituri/rip/offset.py
@@ -26,7 +26,7 @@ import tempfile
 import gobject
 gobject.threads_init()
 
-from morituri.common import logcommand, task, checksum, accurip
+from morituri.common import logcommand, task, checksum, accurip, drive
 from morituri.image import image
 from morituri.program import cdrdao, cdparanoia
 
@@ -45,6 +45,9 @@ CD in the AccurateRip database."""
             help="list of offsets, comma-separated, "
                 "colon-separated for ranges (defaults to %s)" % default,
             default=default)
+        self.parser.add_option('-d', '--device',
+            action="store", dest="device",
+            help="CD-DA device")
 
     def handleOptions(self, options):
         self.options = options
@@ -59,11 +62,23 @@ CD in the AccurateRip database."""
 
         self.debug('Trying with offsets %r', self._offsets)
 
+        if not options.device:
+            drives = drive.getAllDevicePaths()
+            if not drives:
+                self.error('No CD-DA drives found!')
+                return 3
+        
+            # pick the first
+            self.options.device = drives[0]
+
+        # this can be a symlink to another device
+
+
     def do(self, args):
         runner = task.SyncRunner()
 
         # first get the Table Of Contents of the CD
-        t = cdrdao.ReadTOCTask()
+        t = cdrdao.ReadTOCTask(device=self.options.device)
 
         runner.run(t)
         table = t.table

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list