summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/robust.py
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-30 23:33:17 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-30 23:33:17 +0000
commitb3c458f96706b7a6ef570434c9c9adc7129912a4 (patch)
tree147d094408050f337c1ac9b752f61e3be7a23bda /rdiff-backup/rdiff_backup/robust.py
parent316b6ac203137fc5740d1181c941aab1178eeaae (diff)
downloadrdiff-backup-b3c458f96706b7a6ef570434c9c9adc7129912a4.tar.gz
Bug fixes to resuming and error correction code
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@112 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/robust.py')
-rw-r--r--rdiff-backup/rdiff_backup/robust.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py
index 74e0d12..d7040dc 100644
--- a/rdiff-backup/rdiff_backup/robust.py
+++ b/rdiff-backup/rdiff_backup/robust.py
@@ -68,6 +68,7 @@ class RobustAction:
return self.final_func(init_val)
except Exception, exc: # Catch all errors
Log.exception()
+ TracebackArchive.add()
if ran_init_thunk: self.error_handler(exc, 1, init_val)
else: self.error_handler(exc, None, None)
raise exc
@@ -233,41 +234,59 @@ class Robust:
tf.setdata()
return Robust.make_tf_robustaction(init, tf, rp)
- def check_common_error(init_thunk, error_thunk = lambda exc: None):
- """Execute init_thunk, if error, run error_thunk on exception
+ def check_common_error(error_handler, function, *args):
+ """Apply function to args, if error, run error_handler on exception
This only catches certain exceptions which seems innocent
enough.
"""
- try: return init_thunk()
+ try: return function(*args)
except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException, RdiffException), exc:
+ TracebackArchive.add()
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
- 'EIO', # reported by docv
- 'ETXTBSY' # reported by Campbell on some NT system
- ])):
+ 'EIO', 'ETXTBSY', 'ESRCH', 'EINVAL'])):
Log.exception()
- return error_thunk(exc)
+ if error_handler: return error_handler(exc, *args)
else:
Log.exception(1, 2)
raise
def listrp(rp):
"""Like rp.listdir() but return [] if error, and sort results"""
- def error_thunk(exc):
+ def error_handler(exc):
Log("Error listing directory %s" % rp.path, 2)
return []
- dir_listing = Robust.check_common_error(rp.listdir, error_thunk)
+ dir_listing = Robust.check_common_error(error_handler, rp.listdir)
dir_listing.sort()
return dir_listing
MakeStatic(Robust)
+class TracebackArchive:
+ """Save last 10 caught exceptions, so they can be printed if fatal"""
+ _traceback_strings = []
+ def add(cls):
+ """Add most recent exception to archived list"""
+ cls._traceback_strings.append(Log.exception_to_string())
+ if len(cls._traceback_strings) > 10:
+ cls._traceback_strings = cls._traceback_strings[:10]
+
+ def log(cls):
+ """Print all exception information to log file"""
+ if cls._traceback_strings:
+ Log("------------ Old traceback info -----------\n%s"
+ "-------------------------------------------" %
+ ("\n".join(cls._traceback_strings),), 3)
+
+MakeClass(TracebackArchive)
+
+
class TempFileManager:
"""Manage temp files"""