Ejemplo n.º 1
0
Archivo: cd.py Proyecto: tuomo/morituri
    def handleOptions(self, options):
        if not options.device:
            drives = drive.getAllDevicePaths()
            if not drives:
                self.error('No CD-DA drives found!')
                return 3

            # pick the first
            self.options.device = drives[0]

        # this can be a symlink to another device
        self.options.device = os.path.realpath(self.options.device)
Ejemplo n.º 2
0
    def handleOptions(self, options):
        if not options.device:
            drives = drive.getAllDevicePaths()
            if not drives:
                self.error('No CD-DA drives found!')
                return 3

            # pick the first
            self.options.device = drives[0]

        # this can be a symlink to another device
        self.options.device = os.path.realpath(self.options.device)
Ejemplo n.º 3
0
    def __init__(self, argv, prog_name, opts):
        self.opts = opts  # for Rip.add_arguments()
        self.prog_name = prog_name

        self.init_parser()
        self.add_arguments()

        if hasattr(self, 'subcommands'):
            self.parser.add_argument('remainder',
                                     nargs=argparse.REMAINDER,
                                     help=argparse.SUPPRESS)

        if self.device_option:
            # pick the first drive as default
            drives = drive.getAllDevicePaths()
            if not drives:
                msg = 'No CD-DA drives found!'
                logger.critical(msg)
                # morituri exited with return code 3 here
                raise IOError(msg)
            self.parser.add_argument('-d', '--device',
                                     action="store",
                                     dest="device",
                                     default=drives[0],
                                     help="CD-DA device")

        self.options = self.parser.parse_args(argv, namespace=opts)

        if self.device_option:
            # this can be a symlink to another device
            self.options.device = os.path.realpath(self.options.device)
            if not os.path.exists(self.options.device):
                msg = 'CD-DA device %s not found!' % self.options.device
                logger.critical(msg)
                raise IOError(msg)

        self.handle_arguments()

        if hasattr(self, 'subcommands'):
            if not self.options.remainder:
                self.parser.print_help()
                sys.exit(0)
            if not self.options.remainder[0] in self.subcommands:
                sys.stderr.write("incorrect subcommand: %s" %
                                 self.options.remainder[0])
                sys.exit(1)
            self.cmd = self.subcommands[self.options.remainder[0]](
                self.options.remainder[1:],
                prog_name + " " + self.options.remainder[0],
                self.options
            )
Ejemplo n.º 4
0
    def do(self):
        paths = drive.getAllDevicePaths()
        self.config = config.Config()

        if not paths:
            sys.stdout.write('No drives found.\n')
            sys.stdout.write('Create /dev/cdrom if you have a CD drive, \n')
            sys.stdout.write('or install pycdio for better detection.\n')

            return

        try:
            import cdio as _
        except ImportError:
            sys.stdout.write(
                'Install pycdio for vendor/model/release detection.\n')
            return

        for path in paths:
            vendor, model, release = drive.getDeviceInfo(path)
            sys.stdout.write(
                "drive: %s, vendor: %s, model: %s, release: %s\n" % (
                path, vendor, model, release))

            try:
                offset = self.config.getReadOffset(
                    vendor, model, release)
                sys.stdout.write(
                    "       Configured read offset: %d\n" % offset)
            except KeyError:
                sys.stdout.write(
                    "       No read offset found.  Run 'whipper offset find'\n")

            try:
                defeats = self.config.getDefeatsCache(
                    vendor, model, release)
                sys.stdout.write(
                    "       Can defeat audio cache: %s\n" % defeats)
            except KeyError:
                sys.stdout.write(
                    "       Unknown whether audio cache can be defeated. "
                    "Run 'whipper drive analyze'\n")


        if not paths:
            sys.stdout.write('No drives found.\n')
Ejemplo n.º 5
0
    def do(self, args):
        paths = drive.getAllDevicePaths()

        if not paths:
            self.stdout.write('No drives found.\n')
            self.stdout.write('Create /dev/cdrom if you have a CD drive, \n')
            self.stdout.write('or install pycdio for better detection.\n')

            return

        try:
            import cdio as _
        except ImportError:
            self.stdout.write(
                'Install pycdio for vendor/model/release detection.\n')
            return

        for path in paths:
            vendor, model, release = drive.getDeviceInfo(path)
            self.stdout.write(
                "drive: %s, vendor: %s, model: %s, release: %s\n" % (
                path, vendor, model, release))

            try:
                offset = self.getRootCommand().config.getReadOffset(
                    vendor, model, release)
                self.stdout.write(
                    "       Configured read offset: %d\n" % offset)
            except KeyError:
                self.stdout.write(
                    "       No read offset found.  Run 'rip offset find'\n")

            try:
                defeats = self.getRootCommand().config.getDefeatsCache(
                    vendor, model, release)
                self.stdout.write(
                    "       Can defeat audio cache: %s\n" % defeats)
            except KeyError:
                self.stdout.write(
                    "       Unknown whether audio cache can be defeated. "
                    "Run 'rip drive analyze'\n")


        if not paths:
            self.stdout.write('No drives found.\n')
Ejemplo n.º 6
0
    def handleOptions(self, options):
        self.options = options
        self._offsets = []
        blocks = options.offsets.split(',')
        for b in blocks:
            if ':' in b:
                a, b = b.split(':')
                self._offsets.extend(range(int(a), int(b) + 1))
            else:
                self._offsets.append(int(b))

        self.debug('Trying with offsets %r', self._offsets)

        if not options.device:
            drives = drive.getAllDevicePaths()
            if not drives:
                self.error('No CD-DA drives found!')
                return 3

            # pick the first
            self.options.device = drives[0]
Ejemplo n.º 7
0
    def handleOptions(self, options):
        self.options = options
        self._offsets = []
        blocks = options.offsets.split(",")
        for b in blocks:
            if ":" in b:
                a, b = b.split(":")
                self._offsets.extend(range(int(a), int(b) + 1))
            else:
                self._offsets.append(int(b))

        self.debug("Trying with offsets %r", self._offsets)

        if not options.device:
            drives = drive.getAllDevicePaths()
            if not drives:
                self.error("No CD-DA drives found!")
                return 3

            # pick the first
            self.options.device = drives[0]
Ejemplo n.º 8
0
    def do(self, args):
        paths = drive.getAllDevicePaths()

        if not paths:
            print 'No drives found.'
            print 'Create /dev/cdrom if you have a CD drive, '
            print 'or install pycdio for better detection.'

            return

        try:
            import cdio
        except ImportError:
            print 'Install pycdio for vendor/model/release detection.'
            return

        for path in paths:
            device = cdio.Device(path)
            ok, vendor, model, release = device.get_hwinfo()
            print "drive: %s, vendor: %s, model: %s, release: %s" % (
                path, vendor, model, release)

        if not paths:
            print 'No drives found.'
Ejemplo n.º 9
0
    def do(self, args):
        paths = drive.getAllDevicePaths()

        if not paths:
            print 'No drives found.'
            print 'Create /dev/cdrom if you have a CD drive, '
            print 'or install pycdio for better detection.'

            return

        try:
            import cdio
        except ImportError:
            print 'Install pycdio for vendor/model/release detection.'
            return

        for path in paths:
            device = cdio.Device(path)
            ok, vendor, model, release = device.get_hwinfo()
            print "drive: %s, vendor: %s, model: %s, release: %s" % (
                path, vendor, model, release)

        if not paths:
            print 'No drives found.'