summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-10-05 16:10:01 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-10-05 16:10:01 +0000
commitb148c04208515eb3bd781c8c868cba147a5e8458 (patch)
treee5fe26eba4bfdc6d1f9fc96d8c8ed2ec9744ea89
parent38df0d1a59d2c1fe80c563b39706047bd7ba94b5 (diff)
downloadrdiff-backup-b148c04208515eb3bd781c8c868cba147a5e8458.tar.gz
A couple logging bugfixes
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@219 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/rdiff_backup/robust.py40
-rw-r--r--rdiff-backup/src/robust.py40
2 files changed, 50 insertions, 30 deletions
diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py
index 97bfb50..081aba3 100644
--- a/rdiff-backup/rdiff_backup/robust.py
+++ b/rdiff-backup/rdiff_backup/robust.py
@@ -247,29 +247,38 @@ class Robust:
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.
+ This uses the catch_error predicate below to only catch
+ certain exceptions which seems innocent enough.
"""
try: return function(*args)
- except (EnvironmentError, SkipFileException, DSRPPermError,
- RPathException, Rdiff.RdiffException,
- librsync.librsyncError, C.UnknownFileTypeError), exc:
- TracebackArchive.add([function] + args)
- if (not isinstance(exc, EnvironmentError) or
- (errno.errorcode[exc[0]] in
- ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
- 'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
- 'EIO', 'ETXTBSY', 'ESRCH', 'EINVAL'])):
+ except Exception, exc:
+ TracebackArchive.add([function] + list(args))
+ if Robust.catch_error(exc):
Log.exception()
conn = Globals.backup_writer
if conn is not None: # increment error count
ITRB_exists = conn.Globals.is_not_None('ITRB')
if ITRB_exists: conn.Globals.ITRB.increment_stat('Errors')
if error_handler: return error_handler(exc, *args)
- else:
- Log.exception(1, 2)
- raise
+ else: return
+ Log.exception(1, 2)
+ raise
+
+ def catch_error(exc):
+ """Return true if exception exc should be caught"""
+ for exception_class in (SkipFileException, DSRPPermError,
+ RPathException, Rdiff.RdiffException,
+ 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')):
+ return 1
+ return 0
def listrp(rp):
"""Like rp.listdir() but return [] if error, and sort results"""
@@ -314,7 +323,7 @@ class TracebackArchive:
def log(cls):
"""Print all exception information to log file"""
if cls._traceback_strings:
- Log("------------ Old traceback info -----------\n%s"
+ Log("------------ Old traceback info -----------\n%s\n"
"-------------------------------------------" %
("\n".join(cls._traceback_strings),), 3)
@@ -678,3 +687,4 @@ from log import *
from destructive_stepping import *
import Time, Rdiff, librsync
from highlevel import *
+
diff --git a/rdiff-backup/src/robust.py b/rdiff-backup/src/robust.py
index 97bfb50..081aba3 100644
--- a/rdiff-backup/src/robust.py
+++ b/rdiff-backup/src/robust.py
@@ -247,29 +247,38 @@ class Robust:
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.
+ This uses the catch_error predicate below to only catch
+ certain exceptions which seems innocent enough.
"""
try: return function(*args)
- except (EnvironmentError, SkipFileException, DSRPPermError,
- RPathException, Rdiff.RdiffException,
- librsync.librsyncError, C.UnknownFileTypeError), exc:
- TracebackArchive.add([function] + args)
- if (not isinstance(exc, EnvironmentError) or
- (errno.errorcode[exc[0]] in
- ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
- 'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
- 'EIO', 'ETXTBSY', 'ESRCH', 'EINVAL'])):
+ except Exception, exc:
+ TracebackArchive.add([function] + list(args))
+ if Robust.catch_error(exc):
Log.exception()
conn = Globals.backup_writer
if conn is not None: # increment error count
ITRB_exists = conn.Globals.is_not_None('ITRB')
if ITRB_exists: conn.Globals.ITRB.increment_stat('Errors')
if error_handler: return error_handler(exc, *args)
- else:
- Log.exception(1, 2)
- raise
+ else: return
+ Log.exception(1, 2)
+ raise
+
+ def catch_error(exc):
+ """Return true if exception exc should be caught"""
+ for exception_class in (SkipFileException, DSRPPermError,
+ RPathException, Rdiff.RdiffException,
+ 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')):
+ return 1
+ return 0
def listrp(rp):
"""Like rp.listdir() but return [] if error, and sort results"""
@@ -314,7 +323,7 @@ class TracebackArchive:
def log(cls):
"""Print all exception information to log file"""
if cls._traceback_strings:
- Log("------------ Old traceback info -----------\n%s"
+ Log("------------ Old traceback info -----------\n%s\n"
"-------------------------------------------" %
("\n".join(cls._traceback_strings),), 3)
@@ -678,3 +687,4 @@ from log import *
from destructive_stepping import *
import Time, Rdiff, librsync
from highlevel import *
+