def do(self): paths = drive.getAllDevicePaths() self.config = config.Config() if not paths: logger.critical('no drives found. Create /dev/cdrom ' 'if you have a CD drive, or install ' 'pycdio for better detection') return try: import cdio as _ # noqa: F401 (TODO: fix it in a separate PR?) except ImportError: logger.error('install pycdio for vendor/model/release detection') return for path in paths: vendor, model, release = drive.getDeviceInfo(path) print("drive: %s, vendor: %s, model: %s, release: %s" % (path, vendor, model, release)) try: offset = self.config.getReadOffset(vendor, model, release) print(" Configured read offset: %d" % offset) except KeyError: # Note spaces at the beginning for pretty terminal output logger.warning("no read offset found. " "Run 'whipper offset find'") try: defeats = self.config.getDefeatsCache(vendor, model, release) print(" Can defeat audio cache: %s" % defeats) except KeyError: logger.warning("unknown whether audio cache can be " "defeated. Run 'whipper drive analyze'")
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) # whipper 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: logger.critical("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 )
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) # whipper 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: logger.critical("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)
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 _ # noqa: F401 (TODO: fix it in a separate PR?) 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: # Note spaces at the beginning for pretty terminal output 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')
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')
def do(self): paths = drive.getAllDevicePaths() self.config = config.Config() if not paths: logger.critical('no drives found. Create /dev/cdrom ' 'if you have a CD drive, or install ' 'pycdio for better detection') return try: import cdio as _ # noqa: F401 (TODO: fix it in a separate PR?) except ImportError: logger.error('install pycdio for vendor/model/release detection') return for path in paths: vendor, model, release = drive.getDeviceInfo(path) print("drive: %s, vendor: %s, model: %s, release: %s" % ( path, vendor, model, release)) try: offset = self.config.getReadOffset( vendor, model, release) print(" Configured read offset: %d" % offset) except KeyError: # Note spaces at the beginning for pretty terminal output logger.warning("no read offset found. " "Run 'whipper offset find'") try: defeats = self.config.getDefeatsCache( vendor, model, release) print(" Can defeat audio cache: %s" % defeats) except KeyError: logger.warning("unknown whether audio cache can be " "defeated. Run 'whipper drive analyze'")
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() config_section = prog_name.replace(' ', '.') defaults = {} for action in self.parser._actions: val = None if isinstance(action, argparse._StoreAction): val = config.Config().get(config_section, action.dest) elif isinstance( action, (argparse._StoreTrueAction, argparse._StoreFalseAction)): val = config.Config().getboolean(config_section, action.dest) if val is not None: defaults[action.dest] = val self.parser.set_defaults(**defaults) 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) # whipper 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() raise SystemExit() if not self.options.remainder[0] in self.subcommands: logger.critical("incorrect subcommand: %s", self.options.remainder[0]) raise SystemExit(1) self.cmd = self.subcommands[self.options.remainder[0]]( self.options.remainder[1:], prog_name + " " + self.options.remainder[0], self.options)
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() config_section = prog_name.replace(' ', '.') defaults = {} for action in self.parser._actions: val = None if isinstance(action, argparse._StoreAction): val = config.Config().get(config_section, action.dest) elif isinstance(action, (argparse._StoreTrueAction, argparse._StoreFalseAction)): val = config.Config().getboolean(config_section, action.dest) if val is not None: defaults[action.dest] = val self.parser.set_defaults(**defaults) 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) # whipper 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: logger.critical("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 )