From b2a74e14c60af3570edb851619b243ed0047051b Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 20 Mar 2011 18:32:02 +0000 Subject: [PATCH] * morituri/program/cdparanoia.py: Extend FileSizeError with an extra message. * morituri/rip/offset.py: Print a reasonable warning when we cannot rip with a certain offset. See #57. --- ChangeLog | 8 ++++++++ morituri/program/cdparanoia.py | 16 +++++++++++----- morituri/rip/offset.py | 16 ++++++++++++++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f655bb4..739fc09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-20 Thomas Vander Stichele + + * morituri/program/cdparanoia.py: + Extend FileSizeError with an extra message. + * morituri/rip/offset.py: + Print a reasonable warning when we cannot rip with a certain offset. + See #57. + 2011-03-17 Thomas Vander Stichele * morituri/rip/drive.py: diff --git a/morituri/program/cdparanoia.py b/morituri/program/cdparanoia.py index 2eb1236..f2b40a2 100644 --- a/morituri/program/cdparanoia.py +++ b/morituri/program/cdparanoia.py @@ -34,9 +34,10 @@ class FileSizeError(Exception): """ The given path does not have the expected size. """ - def __init__(self, path): - self.args = (path, ) + def __init__(self, path, message): + self.args = (path, message) self.path = path + self.message = message class ReturnCodeError(Exception): """ @@ -311,10 +312,14 @@ class ReadTrackTask(task.Task): self.warning('file size %d did not match expected size %d', size, expected) if (size - expected) % common.BYTES_PER_FRAME == 0: - print 'ERROR: %d frames difference' % ( - (size - expected) / common.BYTES_PER_FRAME) + self.warning('%d frames difference' % ( + (size - expected) / common.BYTES_PER_FRAME)) + else: + self.warning('non-integral amount of frames difference') - self.exception = FileSizeError(self.path) + self.setAndRaiseException(FileSizeError(self.path, + "File size %d did not match expected size %d" % ( + size, expected))) if not self.exception and self._popen.returncode != 0: if self._errors: @@ -426,6 +431,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask): self.info('Checksums match, %08x' % c1) self.checksum = self.testchecksum else: + # FIXME: detect this before encoding self.error('read and verify failed') if self.tasks[5].checksum != self.checksum: diff --git a/morituri/rip/offset.py b/morituri/rip/offset.py index c4afe9a..81266a9 100644 --- a/morituri/rip/offset.py +++ b/morituri/rip/offset.py @@ -136,7 +136,12 @@ CD in the AccurateRip database.""" for offset in self._offsets: print 'Trying read offset %d ...' % offset - archecksum = self._arcs(runner, table, 1, offset) + try: + archecksum = self._arcs(runner, table, 1, offset) + except task.TaskException, e: + if isinstance(e.exception, cdparanoia.FileSizeError): + print 'WARNING: cannot rip with offset %d...' % offset + continue self.debug('AR checksum calculated: %s' % archecksum) @@ -148,7 +153,14 @@ CD in the AccurateRip database.""" # now try and rip all other tracks as well for track in range(2, len(table.tracks) + 1): - archecksum = self._arcs(runner, table, track, offset) + try: + archecksum = self._arcs(runner, table, track, offset) + except task.TaskException, e: + if isinstance(e.exception, cdparanoia.FileSizeError): + print 'WARNING: cannot rip with offset %d...' % \ + offset + continue + c, i = match(archecksum, track, responses) if c: self.debug('MATCHED track %d against response %d' % (