* morituri/common/config.py:

* morituri/rip/cd.py:
	* morituri/rip/drive.py:
	  Handle missing config better.
	  Fixes #111.
This commit is contained in:
Thomas Vander Stichele
2013-01-06 21:31:03 +00:00
parent 25947c369d
commit d9bf584c13
4 changed files with 25 additions and 6 deletions

View File

@@ -1,3 +1,11 @@
2013-01-06 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/config.py:
* morituri/rip/cd.py:
* morituri/rip/drive.py:
Handle missing config better.
Fixes #111.
2013-01-02 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/config.py:

View File

@@ -81,7 +81,12 @@ class Config(log.Loggable):
"""
section = self._findDriveSection(vendor, model, release)
return int(self._parser.get(section, 'read_offset'))
try:
return int(self._parser.get(section, 'read_offset'))
except ConfigParser.NoOptionError:
raise KeyError("Could not find read_offset for %s/%s/%s" % (
vendor, model, release))
def setDefeatsCache(self, vendor, model, release, defeat):
"""
@@ -96,7 +101,11 @@ class Config(log.Loggable):
def getDefeatsCache(self, vendor, model, release):
section = self._findDriveSection(vendor, model, release)
return bool(self._parser.get(section, 'defeats_cache'))
try:
return bool(self._parser.get(section, 'defeats_cache'))
except ConfigParser.NoOptionError:
raise KeyError("Could not find defeats_cache for %s/%s/%s" % (
vendor, model, release))
def write(self):
fd, path = tempfile.mkstemp(suffix=u'.moriturirc')
@@ -126,7 +135,8 @@ class Config(log.Loggable):
return name
raise KeyError
raise KeyError("Could not find configuration section for %s/%s/%s" % (
vendor, model, release))
def _findOrCreateDriveSection(self, vendor, model, release):
try:

View File

@@ -226,8 +226,8 @@ Log files will log the path to tracks relative to this directory.
try:
prog.result.cdparanoiaDefeatsCache = self.getRootCommand(
).config.getDefeatsCache(*info)
except (KeyError, ConfigParser.NoOptionError):
pass
except KeyError, e:
self.debug('Got key error: %r' % (e, ))
prog.result.offset = int(self.options.offset)
prog.result.artist = prog.metadata and prog.metadata.artist \
or 'Unknown Artist'

View File

@@ -110,7 +110,8 @@ class List(logcommand.LogCommand):
self.stdout.write(
" Configured read offset: %d\n" % offset)
except KeyError:
pass
self.stdout.write(
"No read offset found. Run 'rip offset find'\n")
if not paths:
self.stdout.write('No drives found.\n')