コード例 #1
0
ファイル: drive.py プロジェクト: vsq/whipper_freedb
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
ファイル: test_program_soxi.py プロジェクト: sqozz/whipper
    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)
コード例 #6
0
ファイル: image.py プロジェクト: Emgalai/whipper
    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
コード例 #7
0
ファイル: image.py プロジェクト: Emgalai/whipper
    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"
コード例 #8
0
    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)
コード例 #9
0
 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)