display exceptions backtraces if debug mode enabled
This commit is contained in:
parent
70b8169a13
commit
64e380635d
2 changed files with 30 additions and 23 deletions
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from logging import debug
|
||||
from copy import copy
|
||||
import logging
|
||||
from logging import debug
|
||||
from threading import Thread, Event, RLock, Timer
|
||||
from .tools.misc import get_backtrace
|
||||
|
||||
|
|
@ -28,7 +29,9 @@ __all__ = ['BackendsCall', 'CallErrors']
|
|||
class CallErrors(Exception):
|
||||
def __init__(self, errors):
|
||||
Exception.__init__(self, u'These errors have been raised in backend threads:\n%s' % (
|
||||
u'\n'.join((u' * %s: %s\n%s' % (backend, error, backtrace)) for backend, error, backtrace in errors)))
|
||||
u'\n'.join((u' * %s: %s%s' % (backend, error, backtrace + '\n'
|
||||
if logging.root.level == logging.DEBUG else ''))
|
||||
for backend, error, backtrace in self.errors)))
|
||||
self.errors = copy(errors)
|
||||
|
||||
def __iter__(self):
|
||||
|
|
|
|||
|
|
@ -1,30 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2010 Romain Bignon
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, version 3 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import re
|
||||
import os
|
||||
import stat
|
||||
from ConfigParser import SafeConfigParser
|
||||
from logging import warning, debug
|
||||
import logging
|
||||
from logging import debug, error, exception, warning
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
|
||||
import weboob.backends
|
||||
from weboob.backend import BaseBackend
|
||||
|
|
@ -146,8 +145,13 @@ class ModulesLoader(object):
|
|||
try:
|
||||
module = Module(name, __import__(name, fromlist=[str(name)]))
|
||||
except ImportError, e:
|
||||
warning('Unable to load module "%s": %s' % (name, e))
|
||||
return
|
||||
msg = 'Unable to load module "%s": %s' % (name, e)
|
||||
if logging.root.level == logging.DEBUG:
|
||||
exception(msg)
|
||||
return
|
||||
else:
|
||||
error(msg)
|
||||
return
|
||||
if name in self.modules:
|
||||
warning('Module "%s" is already loaded (%s)' % self.modules[name].module)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue