def do(self): runner = task.SyncRunner() t = cdparanoia.AnalyzeTask(self.options.device) runner.run(t) if t.defeatsCache is None: sys.stdout.write( 'Cannot analyze the drive. Is there a CD in it?\n') return if not t.defeatsCache: sys.stdout.write( 'cdparanoia cannot defeat the audio cache on this drive.\n') else: sys.stdout.write( 'cdparanoia can defeat the audio cache on this drive.\n') info = drive.getDeviceInfo(self.options.device) if not info: sys.stdout.write('Drive caching behaviour not saved:' 'could not get device info (requires pycdio).\n') return sys.stdout.write( 'Adding drive cache behaviour to configuration file.\n') config.Config().setDefeatsCache(info[0], info[1], info[2], t.defeatsCache)
def do(self): prog = program.Program(config.Config()) runner = task.SyncRunner() for arg in self.options.cuefile: arg = arg.decode('utf-8') cueImage = image.Image(arg) cueImage.setup(runner) # FIXME: this feels like we're poking at internals. prog.cuePath = arg prog.result = result.RipResult() for track in cueImage.table.tracks: tr = result.TrackResult() tr.number = track.number prog.result.tracks.append(tr) verified = False try: verified = prog.verifyImage(runner, cueImage.table) except accurip.EntryNotFound: print('AccurateRip entry not found') accurip.print_report(prog.result) if not verified: sys.exit(1)
def testDefeatsCache(self): self.runner = task.SyncRunner(verbose=False) path = os.path.join(os.path.dirname(__file__), 'cdparanoia', 'PX-L890SA.cdparanoia-A.stderr') t = AnalyzeFileTask(path) self.runner.run(t) self.failUnless(t.defeatsCache)
def testAbsentFile(self): tempdir = tempfile.mkdtemp() path = os.path.join(tempdir, "nonexistent.flac") t = AudioLengthTask(path) runner = task.SyncRunner() self.assertRaises(task.TaskException, runner.run, t, verbose=False) os.rmdir(tempdir)
def _testSuffix(self, suffix): fd, path = tempfile.mkstemp(suffix=suffix) with os.fdopen(fd, "wb") as temptrack: temptrack.write(open(base_track_file, "rb").read()) t = AudioLengthTask(path) runner = task.SyncRunner() runner.run(t, verbose=False) self.assertEquals(t.length, base_track_length) os.unlink(path)
def do(self): prog = program.Program(config.Config(), stdout=sys.stdout) runner = task.SyncRunner() for arg in self.options.cuefile: sys.stdout.write('Retagging image %r\n' % arg) arg = arg.decode('utf-8') cueImage = image.Image(arg) cueImage.setup(runner) mbdiscid = cueImage.table.getMusicBrainzDiscId() sys.stdout.write('MusicBrainz disc id is %s\n' % mbdiscid) sys.stdout.write("MusicBrainz lookup URL %s\n" % cueImage.table.getMusicBrainzSubmitURL()) prog.metadata = prog.getMusicBrainz( cueImage.table, mbdiscid, release=self.options.release_id, # noqa: E501 country=self.options.country, prompt=self.options.prompt) if not prog.metadata: print 'Not in MusicBrainz database, skipping' continue prog.metadata.discid = mbdiscid # FIXME: this feels like we're poking at internals. prog.cuePath = arg prog.result = result.RipResult() for track in cueImage.table.tracks: path = cueImage.getRealPath(track.indexes[1].path) taglist = prog.getTagList(track.number) logger.debug( 'possibly retagging %r from cue path %r with taglist %r', path, arg, taglist) t = encode.SafeRetagTask(path, taglist) runner.run(t) path = os.path.basename(path) if t.changed: print 'Retagged %s' % path else: print '%s already tagged correctly' % path print
def do(self): prog = program.Program(config.Config()) runner = task.SyncRunner() cache = accurip.AccuCache() for arg in self.options.cuefile: arg = arg.decode('utf-8') cueImage = image.Image(arg) cueImage.setup(runner) url = cueImage.table.getAccurateRipURL() responses = cache.retrieve(url) # FIXME: this feels like we're poking at internals. prog.cuePath = arg prog.result = result.RipResult() for track in cueImage.table.tracks: tr = result.TrackResult() tr.number = track.number prog.result.tracks.append(tr) prog.verifyImage(runner, responses) print "\n".join(prog.getAccurateRipResults()) + "\n"
def do(self): runner = task.SyncRunner() t = cdparanoia.AnalyzeTask(self.options.device) runner.run(t) if t.defeatsCache is None: logger.critical('cannot analyze the drive: is there a CD in it?') return if not t.defeatsCache: logger.info('cdparanoia cannot defeat the audio cache ' 'on this drive') else: logger.info('cdparanoia can defeat the audio cache on this drive') info = drive.getDeviceInfo(self.options.device) if not info: logger.error('drive caching behaviour not saved: ' 'could not get device info') return logger.info('adding drive cache behaviour to configuration file') config.Config().setDefeatsCache(info[0], info[1], info[2], t.defeatsCache)
def testLength(self): path = base_track_file t = AudioLengthTask(path) runner = task.SyncRunner() runner.run(t, verbose=False) self.assertEqual(t.length, base_track_length)