# HG changeset patch # User Tero Marttila # Date 1340094659 -10800 # Node ID 0de61433a42fced21bbdb36a6320741acfb5f044 # Parent 4293baf688b1ed03c011e3a5719ea03acc62931b pvl.backup.rsync: raise RsyncError if rsync fails diff -r 4293baf688b1 -r 0de61433a42f pvl/backup/rsync.py --- a/pvl/backup/rsync.py Tue Jun 19 10:35:15 2012 +0300 +++ b/pvl/backup/rsync.py Tue Jun 19 11:30:59 2012 +0300 @@ -20,17 +20,33 @@ def rsync (source, dest, **opts) : """ Run rsync. + + Raises RsyncError if rsync fails. + + XXX: never used anywhere? """ - invoke.command(RSYNC, source, dest, **opts) + try : + invoke.command(RSYNC, source, dest, **opts) + + except invoke.InvokeError as ex : + raise RsyncError(ex) class RSyncCommandFormatError (Exception) : """ - Improper rsync command + Improper rsync command/source. """ pass +class RsyncError (Exception) : + """ + Rsync command invocation failed. + """ + + pass + + class RSyncServer (object) : """ rsync server-mode execution. @@ -54,8 +70,12 @@ log.info("rsync %ss %s %s", ' '.join(options), src, dst) - # invoke directly, no option-handling, nor stdin/out redirection - invoke.invoke(RSYNC, options + [ src, dst ], data=False) + try : + # invoke directly, no option-handling, nor stdin/out redirection + invoke.invoke(RSYNC, options + [ src, dst ], data=False) + + except invoke.InvokeError as ex : + raise RsyncError(ex) class RSyncFSServer (RSyncServer) : """