From 662c14cf6fe2c77b71b983f46fb517d524a03b12 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 7 Jun 2009 13:37:54 +0000 Subject: [PATCH] * morituri/rip/cd.py: Massage into 80 characters per line. Make pycdio/cdio optional. --- ChangeLog | 6 ++++++ morituri/rip/cd.py | 36 +++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a1ae04..15928c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-06-07 Thomas Vander Stichele + + * morituri/rip/cd.py: + Massage into 80 characters per line. + Make pycdio/cdio optional. + 2009-06-07 Thomas Vander Stichele * morituri/rip/drive.py: diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index ef07968..3279371 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -24,8 +24,6 @@ import os import sys import math -import cdio - import gobject gobject.threads_init() @@ -356,7 +354,15 @@ class Rip(logcommand.LogCommand): res.toctable = itable res.artist = metadata and metadata.artist or 'Unknown Artist' res.title = metadata and metadata.title or 'Unknown Title' - _, res.vendor, res.model, __ = cdio.Device(device).get_hwinfo() + # cdio is optional for now + try: + import cdio + _, res.vendor, res.model, __ = cdio.Device(device).get_hwinfo() + except ImportError: + print 'WARNING: pycdio not installed, cannot identify drive' + res.vendor = 'Unknown' + res.model = 'Unknown' + # check for hidden track one audio htoapath = None @@ -370,10 +376,12 @@ class Rip(logcommand.LogCommand): if index: start = index.absolute stop = track.getIndex(1).absolute - print 'Found Hidden Track One Audio from frame %d to %d' % (start, stop) + print 'Found Hidden Track One Audio from frame %d to %d' % ( + start, stop) # rip it - htoapath = getPath(outdir, self.options.track_template, metadata, mbdiscid, 0) + '.' + extension + htoapath = getPath(outdir, self.options.track_template, metadata, + mbdiscid, 0) + '.' + extension dirname = os.path.dirname(htoapath) if not os.path.exists(dirname): os.makedirs(dirname) @@ -403,7 +411,8 @@ class Rip(logcommand.LogCommand): for i, track in enumerate(itable.tracks): # FIXME: rip data tracks differently if not track.audio: - print 'Skipping data track %d' % (i + 1, ) + print 'WARNING: skipping data track %d, not implemented' % ( + i + 1, ) # FIXME: make it work for now track.indexes[1].relative = 0 continue @@ -411,7 +420,8 @@ class Rip(logcommand.LogCommand): trackResult = result.TrackResult() res.tracks.append(trackResult) - path = getPath(outdir, self.options.track_template, metadata, mbdiscid, i + 1) + '.' + extension + path = getPath(outdir, self.options.track_template, metadata, + mbdiscid, i + 1) + '.' + extension trackResult.number = i + 1 trackResult.filename = path @@ -435,7 +445,8 @@ class Rip(logcommand.LogCommand): if t.checksum: print 'Checksums match for track %d' % (i + 1) else: - print 'ERROR: checksums did not match for track %d' % (i + 1) + print 'ERROR: checksums did not match for track %d' % ( + i + 1) trackResult.testcrc = t.testchecksum trackResult.copycrc = t.copychecksum trackResult.peak = t.peak @@ -450,7 +461,8 @@ class Rip(logcommand.LogCommand): ### write disc files - discName = getPath(outdir, self.options.disc_template, metadata, mbdiscid, i) + discName = getPath(outdir, self.options.disc_template, metadata, + mbdiscid, i) dirname = os.path.dirname(discName) if not os.path.exists(dirname): os.makedirs(dirname) @@ -553,14 +565,16 @@ class Rip(logcommand.LogCommand): c = "(max confidence %3d)" % maxConfidence if confidence is not None: if confidence < maxConfidence: - c = "(confidence %3d of %3d)" % (confidence, maxConfidence) + c = "(confidence %3d of %3d)" % ( + confidence, maxConfidence) ar = ", AR [%s]" % response.checksums[i] print "Track %2d: %s %s [%08x]%s" % ( i + 1, status, c, csum, ar) # write log file - discName = getPath(outdir, self.options.disc_template, metadata, mbdiscid, i) + discName = getPath(outdir, self.options.disc_template, metadata, + mbdiscid, i) logPath = '%s.log' % discName logger = result.getLogger() handle = open(logPath, 'w')