* morituri/common/drive.py:
Really make pycdio and cdio optional. * morituri/rip/drive.py: * morituri/rip/offset.py: Use drive.getAllDevicePaths()
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user