From 58a8a3d386a2cba06477ced8cd610b2e15b8f46c Mon Sep 17 00:00:00 2001 From: multikatt Date: Tue, 7 Apr 2015 15:01:12 -0400 Subject: [PATCH] Check for failed ipfs get:s --- beetsplug/ipfs.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/beetsplug/ipfs.py b/beetsplug/ipfs.py index 1658e6075..effc9f674 100644 --- a/beetsplug/ipfs.py +++ b/beetsplug/ipfs.py @@ -16,7 +16,7 @@ from beets import ui from beets.plugins import BeetsPlugin -from subprocess import call +import subprocess from os import rmdir @@ -50,10 +50,17 @@ class IPFSPlugin(BeetsPlugin): except AttributeError: return self._log.info('Adding {0} to ipfs', album_dir) - call(["ipfs", "add", "-r", album_dir]) + subprocess.call(["ipfs", "add", "-r", album_dir]) def ipfs_get(self, lib, _hash): - call(["ipfs", "get", _hash[0]]) + try: + subprocess.check_output(["ipfs", "get", _hash[0]], + stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as err: + self._log.error('Failed to get {0} from ipfs.\n{1}', + _hash[0], err.output) + return False + self._log.info('Getting {0} from ipfs', _hash[0]) imp = ui.commands.TerminalImportSession(lib, loghandler=None, query=None, paths=_hash)