beautify code

This commit is contained in:
Christophe Benz 2010-05-09 23:01:06 +02:00
commit e0eddf0299
2 changed files with 5 additions and 5 deletions

View file

@ -23,13 +23,13 @@ from __future__ import with_statement
from logging import debug from logging import debug
from copy import copy from copy import copy
from threading import Thread, Event, RLock, Timer from threading import Thread, Event, RLock, Timer
from .tools.misc import getBacktrace from .tools.misc import get_backtrace
__all__ = ['BackendsCall', 'CallErrors'] __all__ = ['BackendsCall', 'CallErrors']
class CallErrors(Exception): class CallErrors(Exception):
def __init__(self, errors): def __init__(self, errors):
Exception.__init__(self, "Several errors have been raised:\n%s" % ('\n'.join(['%s: %s' % (b, e) for b, e in errors]))) Exception.__init__(self, u"Several errors have been raised:\n%s" % (u'\n'.join((u'%s: %s' % (b, e)) for b, e in errors)))
self.errors = copy(errors) self.errors = copy(errors)
def __iter__(self): def __iter__(self):
@ -86,7 +86,7 @@ class BackendsCall(object):
with self.mutex: with self.mutex:
# TODO save backtrace and/or print it here (with debug) # TODO save backtrace and/or print it here (with debug)
self.errors.append((b, e)) self.errors.append((b, e))
debug(getBacktrace(e)) debug(get_backtrace(e))
def _store_result(self, b, r): def _store_result(self, b, r):
with self.mutex: with self.mutex:

View file

@ -23,7 +23,7 @@ import traceback
from dateutil import tz from dateutil import tz
__all__ = ['toUnicode', 'local2utc', 'html2text', 'getBacktrace'] __all__ = ['toUnicode', 'local2utc', 'html2text', 'get_backtrace']
def toUnicode(text): def toUnicode(text):
@ -59,7 +59,7 @@ except ImportError:
def html2text(s): def html2text(s):
return s return s
def getBacktrace(empty="Empty backtrace."): def get_backtrace(empty="Empty backtrace."):
""" """
Try to get backtrace as string. Try to get backtrace as string.
Returns "Error while trying to get backtrace" on failure. Returns "Error while trying to get backtrace" on failure.