From b019e6a5c065444960d48a00c8a3bc9fa2b01b1e Mon Sep 17 00:00:00 2001 From: Yevgeny Bezman Date: Fri, 27 Jun 2014 19:50:41 +0300 Subject: [PATCH] replaygain: silenced errors during import. Fixes #732 --- beetsplug/replaygain.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 4a744afd9..48fc47665 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -25,7 +25,7 @@ from beets.plugins import BeetsPlugin from beets.util import syspath, command_output, displayable_path from beets import config -log = logging.getLogger('beets') +log = logging.getLogger('beets.replaygain') # Utilities. @@ -289,6 +289,7 @@ class GStreamerBackend(object): self.Gst = Gst def compute(self, files, album): + self._error = None self._files = list(files) if len(self._files) == 0: @@ -301,6 +302,9 @@ class GStreamerBackend(object): if self._set_first_file(): self._main_loop.run() + if self._error is not None: + raise self._error + def compute_track_gain(self, items): self.compute(items, False) @@ -345,7 +349,7 @@ class GStreamerBackend(object): self._main_loop.quit() err, debug = message.parse_error() # A GStreamer error, either an unsupported format or a bug. - raise ReplayGainError("Error %s - %s on file %s" % + self._error = ReplayGainError("Error %s - %s on file %s" % (err, debug, self._src.get_property("location"))) def _on_tag(self, bus, message): @@ -557,7 +561,7 @@ class ReplayGainPlugin(BeetsPlugin): if write: item.try_write() except ReplayGainError as e: - log.warn(u"ReplayGain error: {0}".format(e)) + log.info(u"ReplayGain error: {0}".format(e)) except FatalReplayGainError as e: raise ui.UserError( u"Fatal replay gain error: {0}".format(e) @@ -591,7 +595,7 @@ class ReplayGainPlugin(BeetsPlugin): if write: item.try_write() except ReplayGainError as e: - log.warn(u"ReplayGain error: {0}".format(e)) + log.info(u"ReplayGain error: {0}".format(e)) except FatalReplayGainError as e: raise ui.UserError( u"Fatal replay gain error: {0}".format(e) @@ -603,6 +607,8 @@ class ReplayGainPlugin(BeetsPlugin): if not self.automatic: return + log.setLevel(logging.WARN) + if task.is_album: self.handle_album(task.album, False) else: @@ -612,6 +618,8 @@ class ReplayGainPlugin(BeetsPlugin): """Return the "replaygain" ui subcommand. """ def func(lib, opts, args): + log.setLevel(logging.INFO) + write = config['import']['write'].get(bool) if opts.album: