diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-25 08:18:43 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-25 08:18:43 +0000 |
commit | 3f23be3b6e8f61de2ef2d8408c474e22df8cfeb9 (patch) | |
tree | 103076fa7e3c0e636b3ca77f6a58fb5a7664801e /rdiff-backup/rdiff_backup/robust.py | |
parent | 39f64abf52669a32d2d58a7a056b89e6aa5feae7 (diff) | |
download | rdiff-backup-3f23be3b6e8f61de2ef2d8408c474e22df8cfeb9.tar.gz |
More changes in preparation for 0.11.2
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@284 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/robust.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/robust.py | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py index e43ceea..f7f9c01 100644 --- a/rdiff-backup/rdiff_backup/robust.py +++ b/rdiff-backup/rdiff_backup/robust.py @@ -19,7 +19,8 @@ """Catch various exceptions given system call""" -import librsync, errno, signal, C, static, rpath, Globals, log, statistics +import errno, signal +import librsync, C, static, rpath, Globals, log, statistics def check_common_error(error_handler, function, args = []): """Apply function to args, if error, run error_handler on exception @@ -34,9 +35,9 @@ def check_common_error(error_handler, function, args = []): if catch_error(exc): log.Log.exception() conn = Globals.backup_writer - if conn is not None: statistics.record_error() + if conn is not None: conn.statistics.record_error() if error_handler: return error_handler(exc, *args) - else: return + else: return None log.Log.exception(1, 2) raise @@ -46,13 +47,29 @@ def catch_error(exc): librsync.librsyncError, C.UnknownFileTypeError): if isinstance(exc, exception_class): return 1 if (isinstance(exc, EnvironmentError) and - errno.errorcode[exc[0]] in ('EPERM', 'ENOENT', 'EACCES', 'EBUSY', - 'EEXIST', 'ENOTDIR', 'ENAMETOOLONG', - 'EINTR', 'ENOTEMPTY', 'EIO', 'ETXTBSY', - 'ESRCH', 'EINVAL')): + # the invalid mode shows up in backups of /proc for some reason + (exc[0] == 'invalid mode: rb' or + errno.errorcode.has_key(exc[0]) and + errno.errorcode[exc[0]] in ('EPERM', 'ENOENT', 'EACCES', 'EBUSY', + 'EEXIST', 'ENOTDIR', 'ENAMETOOLONG', + 'EINTR', 'ENOTEMPTY', 'EIO', 'ETXTBSY', + 'ESRCH', 'EINVAL'))): return 1 return 0 +def get_error_handler(error_type): + """Return error handler function that can be used above + + Function will just log error to the error_log and then return + None. First two arguments must be the exception and then an rp + (from which the filename will be extracted). + + """ + def error_handler(exc, rp, *args): + log.ErrorLog.write_if_open(error_type, rp, exc) + return 0 + return error_handler + def listrp(rp): """Like rp.listdir() but return [] if error, and sort results""" def error_handler(exc): |