From 4a24671bcee67ad441244eaf0db55fdfc2547880 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 18 Jan 2013 19:36:38 +0100 Subject: [PATCH] better debugging when sampleLength is claimed unknown --- morituri/common/checksum.py | 16 +++++++++++++--- morituri/image/image.py | 7 +++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/morituri/common/checksum.py b/morituri/common/checksum.py index 52debea..96d0260 100644 --- a/morituri/common/checksum.py +++ b/morituri/common/checksum.py @@ -58,13 +58,23 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask): @type sampleStart: int @param sampleStart: the sample to start at """ + + # sampleLength can be e.g. -588 when it is -1 * SAMPLES_PER_FRAME + assert type(path) is unicode, "%r is not unicode" % path self.logName = "ChecksumTask 0x%x" % id(self) # use repr/%r because path can be unicode - self.debug('Creating checksum task on %r from sample %d to sample %d', - path, sampleStart, sampleLength) + if sampleLength < 0: + self.debug( + 'Creating checksum task on %r from sample %d until the end', + path, sampleStart) + else: + self.debug( + 'Creating checksum task on %r from sample %d for %d samples', + path, sampleStart, sampleLength) + if not os.path.exists(path): raise IndexError('%r does not exist' % path) @@ -106,7 +116,7 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask): if qformat == gst.FORMAT_BYTES: self.debug('query returned in BYTES format') length /= 4 - self.debug('total length: %r', length) + self.debug('total sample length of file: %r', length) self._sampleLength = length - self._sampleStart self.debug('audio sample length is %r', self._sampleLength) else: diff --git a/morituri/image/image.py b/morituri/image/image.py index 95c6ea0..5d16f3a 100644 --- a/morituri/image/image.py +++ b/morituri/image/image.py @@ -120,8 +120,11 @@ class AccurateRipChecksumTask(log.Loggable, task.MultiSeparateTask): for trackIndex, track in enumerate(cue.table.tracks): index = track.indexes[1] length = cue.getTrackLength(track) - self.debug('track %d is %d samples long' % ( - trackIndex + 1, length)) + if length < 0: + self.debug('track %d has unknown length' % (trackIndex + 1, )) + else: + self.debug('track %d is %d samples long' % ( + trackIndex + 1, length)) path = image.getRealPath(index.path)