def do(self): runner = task.SyncRunner() # here to avoid import gst eating our options from whipper.common import checksum for f in self.options.files: fromPath = unicode(f) checksumtask = checksum.CRC32Task(fromPath) runner.run(checksumtask) sys.stdout.write('Checksum: %08x\n' % checksumtask.checksum)
def verifyTrack(self, runner, trackResult): t = checksum.CRC32Task(trackResult.filename) try: runner.run(t) except task.TaskException, e: if isinstance(e.exception, common.MissingFrames): logger.warning('missing frames for %r' % trackResult.filename) return False else: raise
def verifyTrack(self, runner, trackResult): is_wave = not trackResult.filename.endswith('.flac') t = checksum.CRC32Task(trackResult.filename, is_wave=is_wave) try: runner.run(t) except task.TaskException as e: if isinstance(e.exception, common.MissingFrames): logger.warning('missing frames for %r', trackResult.filename) return False else: raise ret = trackResult.testcrc == t.checksum logger.debug('verifyTrack: track result crc %r, file crc %r, ' 'result %r', trackResult.testcrc, t.checksum, ret) return ret
def __init__(self, path, table, start, stop, overread, offset=0, device=None, taglist=None, what="track"): task.MultiSeparateTask.__init__(self) logger.debug('Creating read and verify task on %r', path) if taglist: logger.debug('read and verify with taglist %r', taglist) # FIXME: choose a dir on the same disk/dir as the final path fd, tmppath = tempfile.mkstemp(suffix='.whipper.wav') tmppath = unicode(tmppath) os.close(fd) self._tmpwavpath = tmppath from whipper.common import checksum self.tasks = [] self.tasks.append( ReadTrackTask(tmppath, table, start, stop, overread, offset=offset, device=device, what=what)) self.tasks.append(checksum.CRC32Task(tmppath)) t = ReadTrackTask(tmppath, table, start, stop, overread, offset=offset, device=device, action="Verifying", what=what) self.tasks.append(t) self.tasks.append(checksum.CRC32Task(tmppath)) # encode to the final path + '.part' try: tmpoutpath = path + u'.part' open(tmpoutpath, 'wb').close() except IOError as e: if errno.ENAMETOOLONG != e.errno: raise path = common.shrinkPath(path) tmpoutpath = path + u'.part' open(tmpoutpath, 'wb').close() self._tmppath = tmpoutpath self.path = path from whipper.common import encode self.tasks.append(encode.FlacEncodeTask(tmppath, tmpoutpath)) # MerlijnWajer: XXX: We run the CRC32Task on the wav file, because it's # in general stupid to run the CRC32 on the flac file since it already # has --verify. We should just get rid of this CRC32 step. # make sure our encoding is accurate self.tasks.append(checksum.CRC32Task(tmppath)) self.tasks.append(encode.SoxPeakTask(tmppath)) # TODO: Move tagging outside of cdparanoia self.tasks.append(encode.TaggingTask(tmpoutpath, taglist)) self.checksum = None
def __init__(self, path, table, start, stop, overread, offset=0, device=None, taglist=None, what="track", coverArtPath=None): """ Init ReadVerifyTrackTask. :param path: where to store the ripped track :type path: str :param table: table of contents of CD :type table: table.Table :param start: first frame to rip :type start: int :param stop: last frame to rip (inclusive) :type stop: int :param offset: read offset, in samples :type offset: int :param device: the device to rip from :type device: str :param taglist: a dict of tags :type taglist: dict """ task.MultiSeparateTask.__init__(self) logger.debug('creating read and verify task on %r', path) if taglist: logger.debug('read and verify with taglist %r', taglist) # FIXME: choose a dir on the same disk/dir as the final path fd, tmppath = tempfile.mkstemp(suffix='.whipper.wav') os.fchmod(fd, 0o644) os.close(fd) self._tmpwavpath = tmppath from whipper.common import checksum self.tasks = [] self.tasks.append( ReadTrackTask(tmppath, table, start, stop, overread, offset=offset, device=device, what=what)) self.tasks.append(checksum.CRC32Task(tmppath)) t = ReadTrackTask(tmppath, table, start, stop, overread, offset=offset, device=device, action="Verifying", what=what) self.tasks.append(t) self.tasks.append(checksum.CRC32Task(tmppath)) # encode to the final path + '.part' try: tmpoutpath = path + '.part' open(tmpoutpath, 'wb').close() except IOError as e: if errno.ENAMETOOLONG != e.errno: raise path = common.truncate_filename(common.shrinkPath(path)) tmpoutpath = common.truncate_filename(path + '.part') open(tmpoutpath, 'wb').close() self._tmppath = tmpoutpath self.path = path from whipper.common import encode self.tasks.append(encode.FlacEncodeTask(tmppath, tmpoutpath)) # MerlijnWajer: XXX: We run the CRC32Task on the wav file, because it's # in general stupid to run the CRC32 on the flac file since it already # has --verify. We should just get rid of this CRC32 step. # make sure our encoding is accurate self.tasks.append(checksum.CRC32Task(tmppath)) self.tasks.append(encode.SoxPeakTask(tmppath)) # TODO: Move tagging and embed picture outside of cdparanoia self.tasks.append(encode.TaggingTask(tmpoutpath, taglist)) self.tasks.append(encode.EmbedPictureTask(tmpoutpath, coverArtPath)) self.checksum = None