Fix logger statements having multiple arguments

Some of the instructions have been rendered invalid during the conversion to logger statements...

Also performed various stylistic fixes
This commit is contained in:
JoeLametta
2018-12-14 11:02:20 +00:00
parent a23b214814
commit a4f654a3f3
21 changed files with 182 additions and 214 deletions

View File

@@ -40,13 +40,12 @@ retrieves and display accuraterip data from the given URL
count = responses[0].num_tracks
logger.info("Found %d responses for %d tracks",
(len(responses), count))
logger.info("found %d responses for %d tracks", len(responses), count)
for (i, r) in enumerate(responses):
if r.num_tracks != count:
logger.warning("response %d has %d tracks instead of %d", (
i, r.num_tracks, count))
logger.warning("response %d has %d tracks instead of %d",
i, r.num_tracks, count)
# checksum and confidence by track
for track in range(count):
@@ -81,7 +80,7 @@ retrieves and display accuraterip data from the given URL
for highest, checksum in sortedChecksums:
print(" %d result(s) for checksum %s: %s" % (
len(checksums[checksum]),
checksum, str(checksums[checksum])))
checksum, checksums[checksum]))
class AccuRip(BaseCommand):

View File

@@ -176,7 +176,7 @@ class _CD(BaseCommand):
self.program.result.cdparanoiaDefeatsCache = \
self.config.getDefeatsCache(*info)
except KeyError as e:
logger.debug('Got key error: %r' % (e, ))
logger.debug('got key error: %r', (e, ))
self.program.result.artist = self.program.metadata \
and self.program.metadata.artist \
or 'Unknown Artist'
@@ -344,14 +344,14 @@ Log files will log the path to tracks relative to this directory.
# FIXME: turn this into a method
def _ripIfNotRipped(number):
logger.debug('ripIfNotRipped for track %d' % number)
logger.debug('ripIfNotRipped for track %d', number)
# we can have a previous result
trackResult = self.program.result.getTrackResult(number)
if not trackResult:
trackResult = result.TrackResult()
self.program.result.tracks.append(trackResult)
else:
logger.debug('ripIfNotRipped have trackresult, path %r' %
logger.debug('ripIfNotRipped have trackresult, path %r',
trackResult.filename)
path = self.program.getPath(self.program.outdir,
@@ -359,7 +359,7 @@ Log files will log the path to tracks relative to this directory.
self.mbdiscid,
self.program.metadata,
track_number=number) + '.flac'
logger.debug('ripIfNotRipped: path %r' % path)
logger.debug('ripIfNotRipped: path %r', path)
trackResult.number = number
assert isinstance(path, unicode), "%r is not unicode" % path
@@ -376,18 +376,18 @@ Log files will log the path to tracks relative to this directory.
if path != trackResult.filename:
# the path is different (different name/template ?)
# but we can copy it
logger.debug('previous result %r, expected %r' % (
trackResult.filename, path))
logger.debug('previous result %r, expected %r',
trackResult.filename, path)
logger.info('verifying track %d of %d: %s', (
logger.info('verifying track %d of %d: %s',
number, len(self.itable.tracks),
os.path.basename(path).encode('utf-8')))
os.path.basename(path).encode('utf-8'))
if not self.program.verifyTrack(self.runner, trackResult):
logger.warning('verification failed, reripping...')
os.unlink(path)
if not os.path.exists(path):
logger.debug('path %r does not exist, ripping...' % path)
logger.debug('path %r does not exist, ripping...', path)
tries = 0
# we reset durations for test and copy here
trackResult.testduration = 0.0
@@ -397,9 +397,9 @@ Log files will log the path to tracks relative to this directory.
tries += 1
if tries > 1:
extra = " (try %d)" % tries
logger.info('ripping track %d of %d%s: %s', (
logger.info('ripping track %d of %d%s: %s',
number, len(self.itable.tracks), extra,
os.path.basename(path).encode('utf-8')))
os.path.basename(path).encode('utf-8'))
try:
logger.debug('ripIfNotRipped: track %d, try %d',
number, tries)
@@ -415,12 +415,11 @@ Log files will log the path to tracks relative to this directory.
extra))
break
except Exception as e:
logger.debug('Got exception %r on try %d',
e, tries)
logger.debug('got exception %r on try %d', e, tries)
if tries == MAX_TRIES:
logger.critical('Giving up on track %d after %d times' % (
number, tries))
logger.critical('giving up on track %d after %d times',
number, tries)
raise RuntimeError(
"track can't be ripped. "
"Rip attempts number is equal to 'MAX_TRIES'")
@@ -439,12 +438,11 @@ Log files will log the path to tracks relative to this directory.
# HTOA goes on index 0 of track 1
# ignore silence in PREGAP
if trackResult.peak == SILENT:
logger.debug(
'HTOA peak %r is equal to the SILENT '
'threshold, disregarding', trackResult.peak)
logger.debug('HTOA peak %r is equal to the SILENT '
'threshold, disregarding', trackResult.peak)
self.itable.setFile(1, 0, None,
self.ittoc.getTrackStart(1), number)
logger.debug('Unlinking %r', trackResult.filename)
logger.debug('unlinking %r', trackResult.filename)
os.unlink(trackResult.filename)
trackResult.filename = None
logger.info('HTOA discarded, contains digital silence')
@@ -461,15 +459,15 @@ Log files will log the path to tracks relative to this directory.
htoa = self.program.getHTOA()
if htoa:
start, stop = htoa
logger.info('found Hidden Track One Audio from frame %d to %d', (
start, stop))
logger.info('found Hidden Track One Audio from frame %d to %d',
start, stop)
_ripIfNotRipped(0)
for i, track in enumerate(self.itable.tracks):
# FIXME: rip data tracks differently
if not track.audio:
logger.warning('skipping data track %d, not implemented',
(i + 1))
i + 1)
# FIXME: make it work for now
track.indexes[1].relative = 0
continue

View File

@@ -48,7 +48,7 @@ class Analyze(BaseCommand):
info = drive.getDeviceInfo(self.options.device)
if not info:
logger.error('Drive caching behaviour not saved: '
logger.error('drive caching behaviour not saved: '
'could not get device info')
return
@@ -67,7 +67,7 @@ class List(BaseCommand):
self.config = config.Config()
if not paths:
logger.critical('No drives found. Create /dev/cdrom '
logger.critical('no drives found. Create /dev/cdrom '
'if you have a CD drive, or install '
'pycdio for better detection')
return

View File

@@ -50,7 +50,7 @@ def main():
return 255
if isinstance(e.exception, common.EmptyError):
logger.debug("EmptyError: %r", str(e.exception))
logger.debug("EmptyError: %s", e.exception)
logger.critical('could not create encoded file')
return 255

View File

@@ -70,7 +70,7 @@ CD in the AccurateRip database."""
else:
self._offsets.append(int(b))
logger.debug('Trying with offsets %r', self._offsets)
logger.debug('trying with offsets %r', self._offsets)
def do(self):
runner = ctask.SyncRunner()
@@ -97,7 +97,7 @@ CD in the AccurateRip database."""
return
if responses:
logger.debug('%d AccurateRip responses found.' % len(responses))
logger.debug('%d AccurateRip responses found.', len(responses))
if responses[0].cddbDiscId != table.getCDDBDiscId():
logger.warning("AccurateRip response discid different: %s",
responses[0].cddbDiscId)
@@ -125,20 +125,20 @@ CD in the AccurateRip database."""
raise e
if isinstance(e.exception, cdparanoia.FileSizeError):
logger.warning('cannot rip with offset %d...' % offset)
logger.warning('cannot rip with offset %d...', offset)
continue
logger.warning("unknown task exception for offset %d: %r" % (
offset, e))
logger.warning('cannot rip with offset %d...' % offset)
logger.warning("unknown task exception for offset %d: %s",
offset, e)
logger.warning('cannot rip with offset %d...', offset)
continue
logger.debug('AR checksums calculated: %s %s' % archecksums)
logger.debug('AR checksums calculated: %s %s', archecksums)
c, i = match(archecksums, 1, responses)
if c:
count = 1
logger.debug('matched against response %d' % i)
logger.debug('matched against response %d', i)
logger.info('offset of device is likely %d, confirming...',
offset)
@@ -149,14 +149,14 @@ CD in the AccurateRip database."""
archecksums = self._arcs(runner, table, track, offset)
except task.TaskException as e:
if isinstance(e.exception, cdparanoia.FileSizeError):
logger.warning('cannot rip with offset %d...' %
logger.warning('cannot rip with offset %d...',
offset)
continue
c, i = match(archecksums, track, responses)
if c:
logger.debug('MATCHED track %d against response %d' % (
track, i))
logger.debug('matched track %d against response %d',
track, i)
count += 1
if count == len(table.tracks) - 1:
@@ -164,8 +164,8 @@ CD in the AccurateRip database."""
return 0
else:
logger.warning('only %d of %d tracks matched, '
'continuing...',
(count, len(table.tracks)))
'continuing...', count,
len(table.tracks))
logger.error('no matching offset found. '
'Consider trying again with a different disc')