~ubuntu-branches/ubuntu/trusty/duplicity/trusty-updates

« back to all changes in this revision

Viewing changes to duplicity/util.py

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2014-04-29 20:16:15 UTC
  • Revision ID: package-import@ubuntu.com-20140429201615-nadc4mqa2oqbs7bu
Tags: 0.6.23-1ubuntu4.1
* debian/patches/exception-encode.patch:
  - Fix exception when backing up to a directory with utf8 characters
    in its path when using the gio backend (as deja-dup does).
    LP: #1313966
  - Fix a couple more encoding issues during exception handling.  These
    bits aren't as critical, but are bundled in same patch from upstream
    and are still useful.  LP: #1289288, LP: #1311176

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    lines = traceback.format_tb(tb, limit)
47
47
    lines.extend(traceback.format_exception_only(type, value))
48
48
 
49
 
    str = "Traceback (innermost last):\n"
50
 
    str = str + "%-20s %s" % (string.join(lines[:-1], ""),
51
 
                                lines[-1])
 
49
    msg = "Traceback (innermost last):\n"
 
50
    msg = msg + "%-20s %s" % (string.join(lines[:-1], ""), lines[-1])
52
51
 
53
 
    return str
 
52
    return uexc(msg)
54
53
 
55
54
def escape(string):
56
55
    "Convert a (bytes) filename to a format suitable for logging (quoted utf8)"
69
68
    else:
70
69
        return u'.'
71
70
 
 
71
def uexc(e):
 
72
    # Exceptions in duplicity often have path names in them, which if they are
 
73
    # non-ascii will cause a UnicodeDecodeError when implicitly decoding to
 
74
    # unicode.  So we decode manually, using the filesystem encoding.
 
75
    # 99.99% of the time, this will be a fine encoding to use.
 
76
    return ufn(str(e))
 
77
 
72
78
def maybe_ignore_errors(fn):
73
79
    """
74
80
    Execute fn. If the global configuration setting ignore_errors is
83
89
    except Exception, e:
84
90
        if globals.ignore_errors:
85
91
            log.Warn(_("IGNORED_ERROR: Warning: ignoring error as requested: %s: %s")
86
 
                     % (e.__class__.__name__, str(e)))
 
92
                     % (e.__class__.__name__, uexc(e)))
87
93
            return None
88
94
        else:
89
95
            raise