fix image verify:
- accurip.py: raise exception if accuraterip db entry not found - program.py: verify image with only one table, remove redundant check
This commit is contained in:
@@ -486,10 +486,10 @@ Log files will log the path to tracks relative to this directory.
|
|||||||
logger.debug('writing m3u file for %r', discName)
|
logger.debug('writing m3u file for %r', discName)
|
||||||
self.program.write_m3u(discName)
|
self.program.write_m3u(discName)
|
||||||
|
|
||||||
if self.program.verifyImage(self.runner, self.ittoc, self.itable):
|
try:
|
||||||
print('rip verified as accurate')
|
self.program.verifyImage(self.runner, self.ittoc)
|
||||||
else:
|
except accurip.EntryNotFound:
|
||||||
print('rip NOT verified as accurate')
|
print('AccurateRip entry not found')
|
||||||
|
|
||||||
accurip.print_report(self.program.result)
|
accurip.print_report(self.program.result)
|
||||||
|
|
||||||
|
|||||||
@@ -117,16 +117,12 @@ Verifies the image from the given .cue files against the AccurateRip database.
|
|||||||
def do(self):
|
def do(self):
|
||||||
prog = program.Program(config.Config())
|
prog = program.Program(config.Config())
|
||||||
runner = task.SyncRunner()
|
runner = task.SyncRunner()
|
||||||
cache = accurip.AccuCache()
|
|
||||||
|
|
||||||
for arg in self.options.cuefile:
|
for arg in self.options.cuefile:
|
||||||
arg = arg.decode('utf-8')
|
arg = arg.decode('utf-8')
|
||||||
cueImage = image.Image(arg)
|
cueImage = image.Image(arg)
|
||||||
cueImage.setup(runner)
|
cueImage.setup(runner)
|
||||||
|
|
||||||
url = cueImage.table.getAccurateRipURL()
|
|
||||||
responses = cache.retrieve(url)
|
|
||||||
|
|
||||||
# FIXME: this feels like we're poking at internals.
|
# FIXME: this feels like we're poking at internals.
|
||||||
prog.cuePath = arg
|
prog.cuePath = arg
|
||||||
prog.result = result.RipResult()
|
prog.result = result.RipResult()
|
||||||
@@ -135,9 +131,14 @@ Verifies the image from the given .cue files against the AccurateRip database.
|
|||||||
tr.number = track.number
|
tr.number = track.number
|
||||||
prog.result.tracks.append(tr)
|
prog.result.tracks.append(tr)
|
||||||
|
|
||||||
prog.verifyImage(runner, responses)
|
verified = False
|
||||||
|
try:
|
||||||
print "\n".join(prog.getAccurateRipResults()) + "\n"
|
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)
|
||||||
|
|
||||||
|
|
||||||
class Image(BaseCommand):
|
class Image(BaseCommand):
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ ACCURATERIP_URL = "http://www.accuraterip.com/accuraterip/"
|
|||||||
_CACHE_DIR = join(directory.cache_path(), 'accurip')
|
_CACHE_DIR = join(directory.cache_path(), 'accurip')
|
||||||
|
|
||||||
|
|
||||||
|
class EntryNotFound(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class _AccurateRipResponse(object):
|
class _AccurateRipResponse(object):
|
||||||
"""
|
"""
|
||||||
An AccurateRip response contains a collection of metadata identifying a
|
An AccurateRip response contains a collection of metadata identifying a
|
||||||
@@ -175,7 +179,8 @@ def get_db_entry(path):
|
|||||||
if raw_entry:
|
if raw_entry:
|
||||||
_save_entry(raw_entry, cached_path)
|
_save_entry(raw_entry, cached_path)
|
||||||
if not raw_entry:
|
if not raw_entry:
|
||||||
return None
|
logger.warning('entry not found in AccurateRip database')
|
||||||
|
raise EntryNotFound
|
||||||
return _split_responses(raw_entry)
|
return _split_responses(raw_entry)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -558,9 +558,9 @@ class Program:
|
|||||||
t = image.ImageRetagTask(cueImage, taglists)
|
t = image.ImageRetagTask(cueImage, taglists)
|
||||||
runner.run(t)
|
runner.run(t)
|
||||||
|
|
||||||
def verifyImage(self, runner, ittoc, itable):
|
def verifyImage(self, runner, table):
|
||||||
"""
|
"""
|
||||||
verify ittoc against accuraterip and cue_path track lengths
|
verify table against accuraterip and cue_path track lengths
|
||||||
Verify our image against the given AccurateRip responses.
|
Verify our image against the given AccurateRip responses.
|
||||||
|
|
||||||
Needs an initialized self.result.
|
Needs an initialized self.result.
|
||||||
@@ -576,19 +576,9 @@ class Program:
|
|||||||
logger.error(verifytask.exceptionMessage)
|
logger.error(verifytask.exceptionMessage)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
responses = accurip.get_db_entry(ittoc.accuraterip_path())
|
responses = accurip.get_db_entry(table.accuraterip_path())
|
||||||
if not responses:
|
|
||||||
logger.warning('album not found in AccurateRip database')
|
|
||||||
return False
|
|
||||||
logger.info('%d AccurateRip response(s) found' % len(responses))
|
logger.info('%d AccurateRip response(s) found' % len(responses))
|
||||||
|
|
||||||
for r in responses:
|
|
||||||
if r.cddbDiscId != itable.getCDDBDiscId():
|
|
||||||
logger.error(
|
|
||||||
'AccurateRip response discid differs: %s' % r.cddbDiscId
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
checksums = accurip.calculate_checksums([
|
checksums = accurip.calculate_checksums([
|
||||||
os.path.join(os.path.dirname(self.cuePath), t.indexes[1].path)
|
os.path.join(os.path.dirname(self.cuePath), t.indexes[1].path)
|
||||||
for t in filter(lambda t: t.number != 0, cueImage.cue.table.tracks)
|
for t in filter(lambda t: t.number != 0, cueImage.cue.table.tracks)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from unittest import TestCase
|
|||||||
from whipper.common import accurip
|
from whipper.common import accurip
|
||||||
from whipper.common.accurip import (
|
from whipper.common.accurip import (
|
||||||
calculate_checksums, get_db_entry, print_report, verify_result,
|
calculate_checksums, get_db_entry, print_report, verify_result,
|
||||||
_split_responses
|
_split_responses, EntryNotFound
|
||||||
)
|
)
|
||||||
from whipper.result.result import RipResult, TrackResult
|
from whipper.result.result import RipResult, TrackResult
|
||||||
|
|
||||||
@@ -45,8 +45,9 @@ class TestAccurateRipResponse(TestCase):
|
|||||||
# ask cache for other entry and assert cached entry equals normal entry
|
# ask cache for other entry and assert cached entry equals normal entry
|
||||||
self.assertEquals(self.entry, get_db_entry(self.other_path))
|
self.assertEquals(self.entry, get_db_entry(self.other_path))
|
||||||
|
|
||||||
def test_returns_none_for_no_entry(self):
|
def test_raises_entrynotfound_for_no_entry(self):
|
||||||
self.assertIsNone(get_db_entry('definitely_a_404'))
|
with self.assertRaises(EntryNotFound):
|
||||||
|
get_db_entry('definitely_a_404')
|
||||||
|
|
||||||
def test_can_return_entry_without_saving(self):
|
def test_can_return_entry_without_saving(self):
|
||||||
chmod(self.cache_dir, 0)
|
chmod(self.cache_dir, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user