Example #1
0
File: cd.py Project: tuomo/morituri
    def handleOptions(self, options):
        options.track_template = options.track_template.decode('utf-8')
        options.disc_template = options.disc_template.decode('utf-8')

        if options.offset is None:
            info = drive.getDeviceInfo(self.parentCommand.options.device)
            if info:
                try:
                    options.offset = self.getRootCommand(
                        ).config.getReadOffset(*info)
                    self.stdout.write("Using configured read offset %d\n" %
                        options.offset)
                except KeyError:
                    pass

        if options.offset is None:
            options.offset = 0
            self.stdout.write("""WARNING: using default offset %d.
Install pycdio and run 'rip offset find' to detect your drive's offset.
""" %
                        options.offset)
        if self.options.output_directory is None:
            self.options.output_directory = os.getcwd()

        if self.options.logger:
            try:
                klazz = result.getLoggers()[self.options.logger]
            except KeyError:
                self.stderr.write("No logger named %s found!\n" % (
                    self.options.logger))
                raise command.CommandError("No logger named %s" %
                    self.options.logger)

            self.logger = klazz()
Example #2
0
    def handle_arguments(self):
        self.options.output_directory = os.path.expanduser(self.options.output_directory)

        self.options.track_template = self.options.track_template.decode('utf-8')
        self.options.disc_template = self.options.disc_template.decode('utf-8')

        if self.options.offset is None:
            raise ValueError("Drive offset is unconfigured.\n"
                             "Please install pycdio and run 'rip offset "
                             "find' to detect your drive's offset or set it "
                             "manually in the configuration file. It can "
                             "also be specified at runtime using the "
                             "'--offset=value' argument")


        if self.options.working_directory is not None:
            self.options.working_directory = os.path.expanduser(self.options.working_directory)

        if self.options.logger:
            try:
                self.logger = result.getLoggers()[self.options.logger]()
            except KeyError:
                msg = "No logger named %s found!" % self.options.logger
                logger.critical(msg)
                raise ValueError(msg)
Example #3
0
    def handleOptions(self, options):
        options.track_template = options.track_template.decode('utf-8')
        options.disc_template = options.disc_template.decode('utf-8')

        if options.offset is None:
            info = drive.getDeviceInfo(self.parentCommand.options.device)
            if info:
                try:
                    options.offset = self.getRootCommand(
                    ).config.getReadOffset(*info)
                    self.stdout.write("Using configured read offset %d\n" %
                                      options.offset)
                except KeyError:
                    pass

        if options.offset is None:
            options.offset = 0
            self.stdout.write("""WARNING: using default offset %d.
Install pycdio and run 'rip offset find' to detect your drive's offset.
""" % options.offset)
        if self.options.output_directory is None:
            self.options.output_directory = os.getcwd()

        if self.options.logger:
            try:
                klazz = result.getLoggers()[self.options.logger]
            except KeyError:
                self.stderr.write("No logger named %s found!\n" %
                                  (self.options.logger))
                raise command.CommandError("No logger named %s" %
                                           self.options.logger)

            self.logger = klazz()
Example #4
0
    def addOptions(self):
        _CD.addOptions(self)

        loggers = result.getLoggers().keys()

        self.parser.add_option('-L',
                               '--logger',
                               action="store",
                               dest="logger",
                               default='morituri',
                               help="logger to use "
                               "(default '%default', choose from '" +
                               "', '".join(loggers) + "')")
        # FIXME: get from config
        self.parser.add_option(
            '-o',
            '--offset',
            action="store",
            dest="offset",
            help="sample read offset (defaults to configured value, or 0)")
        self.parser.add_option(
            '-O',
            '--output-directory',
            action="store",
            dest="output_directory",
            help="output directory; will be included in file paths in result "
            "files "
            "(defaults to absolute path to current directory; set to "
            "empty if you want paths to be relative instead) ")
        self.parser.add_option(
            '-W',
            '--working-directory',
            action="store",
            dest="working_directory",
            help="working directory; morituri will change to this directory "
            "and files will be created relative to it when not absolute ")

        rcommon.addTemplate(self)

        default = 'flac'

        # here to avoid import gst eating our options
        from morituri.common import encode

        self.parser.add_option(
            '',
            '--profile',
            action="store",
            dest="profile",
            help="profile for encoding (default '%s', choices '%s')" %
            (default, "', '".join(encode.PROFILES.keys())),
            default=default)
        self.parser.add_option(
            '-U',
            '--unknown',
            action="store_true",
            dest="unknown",
            help="whether to continue ripping if the CD is unknown (%default)",
            default=False)
Example #5
0
    def addOptions(self):
        loggers = result.getLoggers().keys()

        self.parser.add_option('-L', '--logger',
            action="store", dest="logger",
            default='morituri',
            help="logger to use "
                "(default '%default', choose from '" +
                    "', '".join(loggers) + "')")
Example #6
0
    def add_arguments(self):
        loggers = result.getLoggers().keys()

        self.parser.add_argument(
            '-L', '--logger',
            action="store", dest="logger",
            default='morituri',
            help="logger to use (choose from '" + "', '".join(loggers) + "')"
        )
Example #7
0
    def addOptions(self):
        loggers = result.getLoggers().keys()

        self.parser.add_option('-L', '--logger',
            action="store", dest="logger",
            default='morituri',
            help="logger to use "
                "(default '%default', choose from '" +
                    "', '".join(loggers) + "')")
Example #8
0
    def addOptions(self):
        _CD.addOptions(self)

        loggers = result.getLoggers().keys()

        self.parser.add_option('-L', '--logger',
            action="store", dest="logger",
            default='morituri',
            help="logger to use "
                "(default '%default', choose from '" +
                    "', '".join(loggers) + "')")
        # FIXME: get from config
        self.parser.add_option('-o', '--offset',
            action="store", dest="offset",
            help="sample read offset (defaults to configured value, or 0)")
        self.parser.add_option('-x', '--force-overread',
            action="store_true", dest="overread",
            help="Force overreading into the lead-out portion of the disc. "
                "Works only if the patched cdparanoia package is installed "
                "and the drive supports this feature. "
                "The default value is: %default",
            default=False)
        self.parser.add_option('-O', '--output-directory',
            action="store", dest="output_directory",
            help="output directory; will be included in file paths in result "
                "files "
                "(defaults to absolute path to current directory; set to "
                "empty if you want paths to be relative instead; "
                "configured value: %default) ")
        self.parser.add_option('-W', '--working-directory',
            action="store", dest="working_directory",
            help="working directory; morituri will change to this directory "
                "and files will be created relative to it when not absolute "
                "(configured value: %default) ")

        rcommon.addTemplate(self)

        default = 'flac'

        # here to avoid import gst eating our options
        from morituri.common import encode

        self.parser.add_option('', '--profile',
            action="store", dest="profile",
            help="profile for encoding (default '%%default', choices '%s')" % (
                "', '".join(encode.PROFILES.keys())),
            default=default)
        self.parser.add_option('-U', '--unknown',
            action="store_true", dest="unknown",
            help="whether to continue ripping if the CD is unknown (%default)",
            default=False)
Example #9
0
    def addOptions(self):
        loggers = result.getLoggers().keys()

        self.parser.add_option('-L', '--logger',
            action="store", dest="logger",
            default='morituri',
            help="logger to use "
                "(default '%default', choose from '" +
                    "', '".join(loggers) + "')")
        # FIXME: get from config
        self.parser.add_option('-o', '--offset',
            action="store", dest="offset",
            help="sample read offset (defaults to configured value, or 0)")
        self.parser.add_option('-O', '--output-directory',
            action="store", dest="output_directory",
            help="output directory; will be included in file paths in result "
                "files "
                "(defaults to absolute path to current directory; set to "
                "empty if you want paths to be relative instead) ")
        self.parser.add_option('-W', '--working-directory',
            action="store", dest="working_directory",
            help="working directory; morituri will change to this directory "
                "and files will be created relative to it when not absolute ")
        # FIXME: have a cache of these pickles somewhere
        self.parser.add_option('-T', '--toc-pickle',
            action="store", dest="toc_pickle",
            help="pickle to use for reading and writing the TOC")

        rcommon.addTemplate(self)

        self.parser.add_option('-R', '--release-id',
            action="store", dest="release_id",
            help="MusicBrainz release id to match to (if there are multiple)")

        default = 'flac'

        # here to avoid import gst eating our options
        from morituri.common import encode

        self.parser.add_option('', '--profile',
            action="store", dest="profile",
            help="profile for encoding (default '%s', choices '%s')" % (
                default, "', '".join(encode.PROFILES.keys())),
            default=default)
        self.parser.add_option('-U', '--unknown',
            action="store_true", dest="unknown",
            help="whether to continue ripping if the CD is unknown (%default)",
            default=False)
Example #10
0
    def add_arguments(self):
        loggers = result.getLoggers().keys()
        default_offset = None
        info = drive.getDeviceInfo(self.opts.device)
        if info:
            try:
                default_offset = config.Config().getReadOffset(*info)
                sys.stdout.write("Using configured read offset %d\n" %
                                  default_offset)
            except KeyError:
                pass

        _CD.add_arguments(self.parser)

        self.parser.add_argument('-L', '--logger',
            action="store", dest="logger", default='morituri',
            help="logger to use (choose from '" + "', '".join(loggers) + "')")
        # FIXME: get from config
        self.parser.add_argument('-o', '--offset',
            action="store", dest="offset", default=default_offset,
            help="sample read offset")
        self.parser.add_argument('-x', '--force-overread',
            action="store_true", dest="overread", default=False,
            help="Force overreading into the lead-out portion of the disc. "
                "Works only if the patched cdparanoia package is installed "
                "and the drive supports this feature. ")
        self.parser.add_argument('-O', '--output-directory',
            action="store", dest="output_directory",
            default=os.path.relpath(os.getcwd()),
            help="output directory; will be included in file paths in log")
        self.parser.add_argument('-W', '--working-directory',
            action="store", dest="working_directory",
            help="working directory; morituri will change to this directory "
                "and files will be created relative to it when not absolute")
        self.parser.add_argument('--track-template',
            action="store", dest="track_template",
            default=DEFAULT_TRACK_TEMPLATE,
            help="template for track file naming (default default)")
        self.parser.add_argument('--disc-template',
            action="store", dest="disc_template",
            default=DEFAULT_DISC_TEMPLATE,
            help="template for disc file naming (default default)")
        self.parser.add_argument('-U', '--unknown',
            action="store_true", dest="unknown",
            help="whether to continue ripping if the CD is unknown",
            default=False)
Example #11
0
    def do(self, args):
        self._cache = cache.ResultCache()

        persisted = self._cache.getRipResult(args[0], create=False)

        if not persisted:
            self.stderr.write("Could not find a result for cddb disc id %s\n" % args[0])
            return 3

        try:
            klazz = result.getLoggers()[self.options.logger]
        except KeyError:
            self.stderr.write("No logger named %s found!\n" % (self.options.logger))
            return 3

        logger = klazz()
        self.stdout.write(logger.log(persisted.object).encode("utf-8"))
Example #12
0
    def do(self, args):
        self._cache = cache.ResultCache()

        persisted = self._cache.getRipResult(args[0], create=False)

        if not persisted:
            self.stderr.write('Could not find a result for cddb disc id %s\n' %
                              args[0])
            return 3

        try:
            klazz = result.getLoggers()[self.options.logger]
        except KeyError:
            self.stderr.write("No logger named %s found!\n" %
                              (self.options.logger))
            return 3

        logger = klazz()
        self.stdout.write(logger.log(persisted.object).encode('utf-8'))
Example #13
0
    def handleOptions(self, options):
        options.track_template = options.track_template.decode('utf-8')
        options.disc_template = options.disc_template.decode('utf-8')

        if options.offset is None:
            info = drive.getDeviceInfo(self.parentCommand.options.device)
            if info:
                try:
                    options.offset = self.getRootCommand(
                    ).config.getReadOffset(*info)
                    self.stdout.write("Using configured read offset %d\n" %
                                      options.offset)
                except KeyError:
                    pass

        if options.offset is None:
            raise ValueError("Drive offset is unconfigured.\n"
                             "Please install pycdio and run 'rip offset "
                             "find' to detect your drive's offset or set it "
                             "manually in the configuration file. It can "
                             "also be specified at runtime using the "
                             "'--offset=value' argument")

        if self.options.output_directory is None:
            self.options.output_directory = os.getcwd()
        else:
            self.options.output_directory = os.path.expanduser(
                self.options.output_directory)

        if self.options.working_directory is not None:
            self.options.working_directory = os.path.expanduser(
                self.options.working_directory)

        if self.options.logger:
            try:
                klazz = result.getLoggers()[self.options.logger]
            except KeyError:
                self.stderr.write("No logger named %s found!\n" %
                                  (self.options.logger))
                raise command.CommandError("No logger named %s" %
                                           self.options.logger)

            self.logger = klazz()
Example #14
0
            if responses[0].cddbDiscId != itable.getCDDBDiscId():
                self.stdout.write(
                    "AccurateRip response discid different: %s\n" %
                    responses[0].cddbDiscId)


        prog.verifyImage(runner, responses)

        self.stdout.write("\n".join(prog.getAccurateRipResults()) + "\n")

        prog.saveRipResult()

        # write log file
        try:
            klazz = result.getLoggers()[self.options.logger]
            prog.writeLog(discName, klazz())
        except KeyError:
            self.stderr.write("No logger named %s found!\n" % (
                self.options.logger))

        prog.ejectDevice(device)


class CD(logcommand.LogCommand):

    summary = "handle CD's"

    subCommandClasses = [Rip, ]

    def addOptions(self):