Logger update
* improved code clarity * added a bit of documentation * removed peak level's erroneous percent sign * removed morituri compatibility code paths
This commit is contained in:
@@ -13,40 +13,50 @@ class MorituriLogger(result.Logger):
|
||||
_errors = False
|
||||
|
||||
def log(self, ripResult, epoch=time.time()):
|
||||
"""Returns big str: logfile joined text lines"""
|
||||
|
||||
lines = self.logRip(ripResult, epoch=epoch)
|
||||
return "\n".join(lines)
|
||||
|
||||
def logRip(self, ripResult, epoch):
|
||||
"""Returns logfile lines list"""
|
||||
|
||||
lines = []
|
||||
lines.append("Log created by: morituri %s (%s logger)" % (
|
||||
configure.version, ripResult.logger))
|
||||
|
||||
# Ripper version
|
||||
# Only implemented in whipper (ripResult.logger)
|
||||
lines.append("Log created by: whipper %s (%s logger)" % (
|
||||
configure.version, ripResult.logger))
|
||||
|
||||
# Rip date
|
||||
date = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(epoch)).strip()
|
||||
lines.append("Log creation date: %s" % date)
|
||||
lines.append("")
|
||||
|
||||
# Rip technical settings
|
||||
lines.append("Ripping phase information:")
|
||||
lines.append(" Drive: %s%s (revision %s)" % (
|
||||
ripResult.vendor, ripResult.model, ripResult.release))
|
||||
defeat = "Unknown"
|
||||
if ripResult.cdparanoiaDefeatsCache is True:
|
||||
if ripResult.cdparanoiaDefeatsCache is None:
|
||||
defeat = "Unknown"
|
||||
elif ripResult.cdparanoiaDefeatsCache:
|
||||
defeat = "Yes"
|
||||
elif ripResult.cdparanoiaDefeatsCache is False:
|
||||
else:
|
||||
defeat = "No"
|
||||
lines.append(" Defeat audio cache: %s" % defeat)
|
||||
lines.append(" Read offset correction: %+d" % ripResult.offset)
|
||||
# Currently unsupported by the official cdparanoia package
|
||||
over = "No"
|
||||
try:
|
||||
if ripResult.overread is True:
|
||||
over = "Yes"
|
||||
except NameError:
|
||||
pass
|
||||
# Only implemented in whipper (ripResult.overread)
|
||||
if ripResult.overread:
|
||||
over = "Yes"
|
||||
lines.append(" Overread into lead-out: %s" % over)
|
||||
# Next one fully works only using the patched cdparanoia package
|
||||
# lines.append("Fill up missing offset samples with silence: Yes")
|
||||
lines.append(" Gap detection: cdrdao %s" % ripResult.cdrdaoVersion)
|
||||
lines.append("")
|
||||
|
||||
# Rip encoding settings
|
||||
lines.append("Encoding phase information:")
|
||||
lines.append(" Used output format: %s" % ripResult.profileName)
|
||||
lines.append(" GStreamer:")
|
||||
@@ -57,6 +67,7 @@ class MorituriLogger(result.Logger):
|
||||
ripResult.encoderVersion)
|
||||
lines.append("")
|
||||
|
||||
# CD metadata
|
||||
lines.append("CD metadata:")
|
||||
lines.append(" Album: %s - %s" % (ripResult.artist, ripResult.title))
|
||||
lines.append(" CDDB Disc ID: %s" % ripResult. table.getCDDBDiscId())
|
||||
@@ -66,13 +77,18 @@ class MorituriLogger(result.Logger):
|
||||
ripResult. table.getMusicBrainzSubmitURL())
|
||||
lines.append("")
|
||||
|
||||
# TOC section
|
||||
lines.append("TOC:")
|
||||
table = ripResult.table
|
||||
|
||||
# Test for HTOA presence
|
||||
htoa = None
|
||||
try:
|
||||
htoa = table.tracks[0].getIndex(0)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# If True, include HTOA line into log's TOC
|
||||
if htoa and htoa.path:
|
||||
htoastart = htoa.absolute
|
||||
htoaend = table.getTrackEnd(0)
|
||||
@@ -83,6 +99,8 @@ class MorituriLogger(result.Logger):
|
||||
lines.append(" Start sector: %d" % htoastart)
|
||||
lines.append(" End sector: %d" % htoaend)
|
||||
lines.append("")
|
||||
|
||||
# For every track include information in the TOC
|
||||
for t in table.tracks:
|
||||
# FIXME: what happens to a track start over 60 minutes ?
|
||||
# Answer: tested empirically, everything seems OK
|
||||
@@ -96,6 +114,7 @@ class MorituriLogger(result.Logger):
|
||||
lines.append(" End sector: %d" % end)
|
||||
lines.append("")
|
||||
|
||||
# Tracks section
|
||||
lines.append("Tracks:")
|
||||
duration = 0.0
|
||||
for t in ripResult.tracks:
|
||||
@@ -105,6 +124,7 @@ class MorituriLogger(result.Logger):
|
||||
lines.append("")
|
||||
duration += t.testduration + t.copyduration
|
||||
|
||||
# Status report
|
||||
lines.append("Conclusive status report:")
|
||||
arHeading = " AccurateRip summary:"
|
||||
if self._inARDatabase == 0:
|
||||
@@ -134,6 +154,7 @@ class MorituriLogger(result.Logger):
|
||||
lines.append(" EOF: End of status report")
|
||||
lines.append("")
|
||||
|
||||
# Log hash
|
||||
hasher = hashlib.sha256()
|
||||
hasher.update("\n".join(lines).encode("utf-8"))
|
||||
lines.append("SHA-256 hash: %s" % hasher.hexdigest().upper())
|
||||
@@ -141,24 +162,45 @@ class MorituriLogger(result.Logger):
|
||||
return lines
|
||||
|
||||
def trackLog(self, trackResult):
|
||||
"""Returns Tracks section lines: data picked from trackResult"""
|
||||
|
||||
lines = []
|
||||
|
||||
# Track number
|
||||
lines.append(" %02d:" % trackResult.number)
|
||||
|
||||
# Filename (including path) of ripped track
|
||||
lines.append(" Filename: %s" % trackResult.filename)
|
||||
|
||||
# Pre-gap length
|
||||
pregap = trackResult.pregap
|
||||
if pregap:
|
||||
lines.append(" Pre-gap length: %s" % common.framesToMSF(pregap))
|
||||
|
||||
# Peak level
|
||||
peak = trackResult.peak
|
||||
lines.append(" Peak level: %.6f %%" % peak)
|
||||
lines.append(" Peak level: %.6f %" % peak)
|
||||
|
||||
# Extraction speed
|
||||
if trackResult.copyspeed:
|
||||
lines.append(" Extraction speed: %.1f X" % (
|
||||
trackResult.copyspeed))
|
||||
|
||||
# Extraction quality
|
||||
if trackResult.quality and trackResult.quality > 0.001:
|
||||
lines.append(" Track quality: %.2f %%" %
|
||||
lines.append(" Extraction quality: %.2f %%" %
|
||||
(trackResult.quality * 100.0, ))
|
||||
|
||||
# Ripper Test CRC
|
||||
if trackResult.testcrc is not None:
|
||||
lines.append(" Test CRC: %08X" % trackResult.testcrc)
|
||||
|
||||
# Ripper Copy CRC
|
||||
if trackResult.copycrc is not None:
|
||||
lines.append(" Copy CRC: %08X" % trackResult.copycrc)
|
||||
|
||||
# AccurateRip track status
|
||||
# Currently there's no support for AccurateRip V2
|
||||
if trackResult.accurip:
|
||||
lines.append(" AccurateRip V1:")
|
||||
self._inARDatabase += 1
|
||||
@@ -176,6 +218,7 @@ class MorituriLogger(result.Logger):
|
||||
lines.append(" Result: Track not present in "
|
||||
"AccurateRip database")
|
||||
|
||||
# Check if Test & Copy CRCs are equal
|
||||
if trackResult.testcrc == trackResult.copycrc:
|
||||
lines.append(" Status: Copy OK")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user