From e4cbc33583d65935ffff338e10032ae4b18f6568 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 11 Nov 2012 22:39:13 +0000 Subject: [PATCH] pep8 fixes --- morituri/rip/accurip.py | 6 +++--- morituri/rip/cd.py | 29 +++++++++++++++++++++++------ morituri/rip/debug.py | 6 +++--- morituri/rip/drive.py | 6 +++--- morituri/rip/image.py | 8 ++++---- morituri/rip/main.py | 2 +- morituri/rip/offset.py | 18 +++++++++--------- 7 files changed, 46 insertions(+), 29 deletions(-) diff --git a/morituri/rip/accurip.py b/morituri/rip/accurip.py index 5221ff7..d6dd864 100644 --- a/morituri/rip/accurip.py +++ b/morituri/rip/accurip.py @@ -6,17 +6,17 @@ # Copyright (C) 2009 Thomas Vander Stichele # This file is part of morituri. -# +# # morituri is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # morituri is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with morituri. If not, see . diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index ff070a7..01cf537 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -37,6 +37,9 @@ from morituri.extern.task import task DEFAULT_TRACK_TEMPLATE = u'%A - %d/%t. %a - %n' DEFAULT_DISC_TEMPLATE = u'%A - %d/%A - %d' +MAX_TRIES = 5 + + class Rip(logcommand.LogCommand): summary = "rip CD" @@ -224,16 +227,30 @@ See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=1 os.unlink(path) if not os.path.exists(path): + tries = 0 print 'Ripping track %d of %d: %s' % ( number, len(itable.tracks), os.path.basename(path).encode('utf-8')) - prog.ripTrack(runner, trackResult, - offset=int(self.options.offset), - device=self.parentCommand.options.device, - profile=profile, - taglist=prog.getTagList(number), - what='track %d of %d' % (number, len(itable.tracks))) + while tries < MAX_TRIES: + tries += 1 + try: + self.debug('ripIfNotRipped: track %d, try %d', + number, tries) + prog.ripTrack(runner, trackResult, + offset=int(self.options.offset), + device=self.parentCommand.options.device, + profile=profile, + taglist=prog.getTagList(number), + what='track %d of %d' % (number, len(itable.tracks))) + break + except Exception, e: + self.debug('Got exception %r on try %d', + e, tries) + + if tries == MAX_TRIES: + self.error('Giving up on track %d after %d times' % ( + number, tries)) if trackResult.testcrc == trackResult.copycrc: print 'Checksums match for track %d' % (number) else: diff --git a/morituri/rip/debug.py b/morituri/rip/debug.py index b3959a6..edf48cd 100644 --- a/morituri/rip/debug.py +++ b/morituri/rip/debug.py @@ -6,17 +6,17 @@ # Copyright (C) 2009 Thomas Vander Stichele # This file is part of morituri. -# +# # morituri is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # morituri is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with morituri. If not, see . diff --git a/morituri/rip/drive.py b/morituri/rip/drive.py index 7abbad4..4e8d354 100644 --- a/morituri/rip/drive.py +++ b/morituri/rip/drive.py @@ -6,17 +6,17 @@ # Copyright (C) 2009 Thomas Vander Stichele # This file is part of morituri. -# +# # morituri is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # morituri is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with morituri. If not, see . diff --git a/morituri/rip/image.py b/morituri/rip/image.py index dff5fba..bde5e8a 100644 --- a/morituri/rip/image.py +++ b/morituri/rip/image.py @@ -6,17 +6,17 @@ # Copyright (C) 2009 Thomas Vander Stichele # This file is part of morituri. -# +# # morituri is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # morituri is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with morituri. If not, see . @@ -159,7 +159,7 @@ class Verify(logcommand.LogCommand): tr.number = track.number prog.result.tracks.append(tr) - prog.verifyImage(runner, responses) + prog.verifyImage(runner, responses) print "\n".join(prog.getAccurateRipResults()) + "\n" diff --git a/morituri/rip/main.py b/morituri/rip/main.py index 2581948..ee4be17 100644 --- a/morituri/rip/main.py +++ b/morituri/rip/main.py @@ -40,7 +40,7 @@ cdrdao says: log.debug('main', "EmptyError: %r", log.getExceptionMessage(e.exception)) sys.stderr.write( - 'rip: error: Could not create encoded file.\n') + 'rip: error: Could not create encoded file.\n') return 255 raise diff --git a/morituri/rip/offset.py b/morituri/rip/offset.py index 3f2babb..377fe2e 100644 --- a/morituri/rip/offset.py +++ b/morituri/rip/offset.py @@ -6,17 +6,17 @@ # Copyright (C) 2009 Thomas Vander Stichele # This file is part of morituri. -# +# # morituri is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # morituri is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with morituri. If not, see . @@ -79,7 +79,7 @@ CD in the AccurateRip database.""" if not drives: self.error('No CD-DA drives found!') return 3 - + # pick the first self.options.device = drives[0] @@ -106,7 +106,7 @@ CD in the AccurateRip database.""" except cdrdao.DeviceOpenException, e: self.error(e.msg) return 3 - + table = t.table self.debug("CDDB disc id: %r", table.getCDDBDiscId()) @@ -136,7 +136,7 @@ CD in the AccurateRip database.""" # now rip the first track at various offsets, calculating AccurateRip # CRC, and matching it against the retrieved ones - + def match(archecksum, track, responses): for i, r in enumerate(responses): if archecksum == r.checksums[track - 1]: @@ -184,10 +184,10 @@ CD in the AccurateRip database.""" else: print 'Only %d of %d tracks matched, continuing ...' % ( count, len(table.tracks)) - + print 'No matching offset found.' print 'Consider trying again with a different disc.' - + def _arcs(self, runner, table, track, offset): # rips the track with the given offset, return the arcs checksum self.debug('Ripping track %r with offset %d ...', track, offset) @@ -210,7 +210,7 @@ CD in the AccurateRip database.""" t = checksum.AccurateRipChecksumTask(path, trackNumber=track, trackCount=len(table.tracks)) runner.run(t) - + os.unlink(path) return "%08x" % t.checksum