pvl.backup.rsync: raise RsyncError if rsync fails
authorTero Marttila <terom@paivola.fi>
Tue, 19 Jun 2012 11:30:59 +0300
changeset 64 0de61433a42f
parent 63 4293baf688b1
child 65 462cecaa70d0
pvl.backup.rsync: raise RsyncError if rsync fails
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) :
     """