keyfinder: Better output parsing (#1248)

We were being sloppy about bytes output from the process. Also, it seems like
the tools outputs the path also, so it's necessary to break on whitespace to
actually get the key name.
This commit is contained in:
Adrian Sampson 2015-01-20 15:17:21 -08:00
parent dae1776165
commit f617d162cf
2 changed files with 10 additions and 1 deletions

View file

@ -58,11 +58,18 @@ class KeyFinderPlugin(BeetsPlugin):
continue
try:
key = util.command_output([bin, '-f', item.path])
output = util.command_output([bin, '-f', item.path])
except (subprocess.CalledProcessError, OSError) as exc:
self._log.error(u'execution failed: {0}', exc)
continue
key_raw = output.rsplit(None, 1)[-1]
try:
key = key_raw.decode('utf8')
except UnicodeDecodeError:
self._log.error(u'output is invalid UTF-8')
continue
item['initial_key'] = key
self._log.info(u'added computed initial key {0} for {1}',
key, util.displayable_path(item.path))

View file

@ -39,6 +39,8 @@ Fixes:
company since 2013, so we are assuming access will not be restored.
* Incremental imports now (once again) show a "skipped N directories" message.
* :doc:`/plugins/embedart`: Handle errors in ImageMagick's output. :bug:`1241`
* :doc:`/plugins/keyfinder`: Parse the underlying tool's output more robustly.
:bug:`1248`
For developers: