Skip to content

Commit

Permalink
RESOLVED #18, Improve error output
Browse files Browse the repository at this point in the history
UPDATED version to 0.6.5
  • Loading branch information
masc3d committed May 9, 2016
1 parent 34e7e43 commit 154ed85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion btrfs_sxbackup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.

__version__ = '0.6.4'
__version__ = '0.6.5'
__author__ = 'Marco Schindler'
__email__ = 'masc@disappear.de'
__maintainer__ = 'masc@disappear.de'
Expand Down
23 changes: 16 additions & 7 deletions btrfs_sxbackup/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def _log_info(self, msg):
def _log_warn(self, msg):
self.__logger.warn(self._format_log_msg(msg))

def _log_error(self, msg):
self.__logger.error(self._format_log_msg(msg))

def _log_debug(self, msg):
self.__logger.debug(self._format_log_msg(msg))

Expand Down Expand Up @@ -294,14 +297,20 @@ def transfer_btrfs_snapshot(self,
# Wait for commands to complete
send_returncode = send_process.wait()
receive_returncode = receive_process.wait()
if send_returncode:
raise subprocess.CalledProcessError(send_process.returncode,
send_process.args,
send_process.stderr.read())

def log_process_error(proc_returncode, proc_args, proc_out):
proc_out_fmt = proc_out.read().decode().strip()
self._log_error('Command %s failed with error code %d (%s)'
% (proc_args, proc_returncode, proc_out_fmt))

if receive_returncode:
raise subprocess.CalledProcessError(receive_process.returncode,
receive_process.args,
receive_process.stdout.read())
log_process_error(receive_process.returncode, receive_process.args, receive_process.stdout)

if send_returncode:
log_process_error(send_process.returncode, send_process.args, send_process.stderr)

if receive_returncode or send_returncode:
raise Error("Transferring snapshot failed")

except BaseException as e:
try:
Expand Down

0 comments on commit 154ed85

Please sign in to comment.