rdiff-backup-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Rdiff-backup-commits] Changes to rdiff-backup/rdiff_backup/robust.py


From: Ben Escoto
Subject: [Rdiff-backup-commits] Changes to rdiff-backup/rdiff_backup/robust.py
Date: Fri, 18 Nov 2005 22:10:05 -0500

Index: rdiff-backup/rdiff_backup/robust.py
diff -u rdiff-backup/rdiff_backup/robust.py:1.36 
rdiff-backup/rdiff_backup/robust.py:1.37
--- rdiff-backup/rdiff_backup/robust.py:1.36    Tue Nov  1 04:46:16 2005
+++ rdiff-backup/rdiff_backup/robust.py Sat Nov 19 03:10:03 2005
@@ -19,8 +19,8 @@
 
 """Catch various exceptions given system call"""
 
-import errno, signal
-import librsync, C, static, rpath, Globals, log, statistics
+import errno, signal, exceptions
+import librsync, C, static, rpath, Globals, log, statistics, connection
 
 def check_common_error(error_handler, function, args = []):
        """Apply function to args, if error, run error_handler on exception
@@ -38,7 +38,8 @@
                        if conn is not None: conn.statistics.record_error()
                        if error_handler: return error_handler(exc, *args)
                        else: return None
-               log.Log.exception(1, 2)
+               if is_routine_fatal(exc): log.Log.exception(1, 6)
+               else: log.Log.exception(1, 2)
                raise
 
 def catch_error(exc):
@@ -58,6 +59,22 @@
                                                                         
'EDEADLK'))):
                return 1
        return 0
+
+def is_routine_fatal(exc):
+       """Return string if exception is non-error unrecoverable, None otherwise
+
+       Used to suppress a stack trace for exceptions like keyboard
+       interrupts or connection drops.  Return value is string to use as
+       an exit message.
+
+       """
+       if isinstance(exc, exceptions.KeyboardInterrupt):
+               return "User abort"
+       elif isinstance(exc, connection.ConnectionError):
+               return "Lost connection to the remote system"
+       elif isinstance(exc, SignalException):
+               return "Killed with signal %s" % (exc,)
+       return None
 
 def get_error_handler(error_type):
        """Return error handler function that can be used above




reply via email to

[Prev in Thread] Current Thread [Next in Thread]