show a messagebox on bcall errors instead of console print
This commit is contained in:
parent
217b029a6f
commit
41827c4160
2 changed files with 24 additions and 3 deletions
|
|
@ -99,6 +99,7 @@ class BackendsCall(object):
|
||||||
else:
|
else:
|
||||||
result = getattr(backend, function)(*args, **kwargs)
|
result = getattr(backend, function)(*args, **kwargs)
|
||||||
except Exception, error:
|
except Exception, error:
|
||||||
|
debug('%s: Called function %s raised an error: %r' % (backend, function, error))
|
||||||
self._store_error(backend, error)
|
self._store_error(backend, error)
|
||||||
else:
|
else:
|
||||||
debug('%s: Called function %s returned: %r' % (backend, function, result))
|
debug('%s: Called function %s returned: %r' % (backend, function, result))
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,12 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
import re
|
||||||
from PyQt4.QtCore import QTimer, SIGNAL, QObject, QString, QSize
|
from PyQt4.QtCore import QTimer, SIGNAL, QObject, QString, QSize
|
||||||
from PyQt4.QtGui import QMainWindow, QApplication, QStyledItemDelegate, \
|
from PyQt4.QtGui import QMainWindow, QApplication, QStyledItemDelegate, \
|
||||||
QStyleOptionViewItemV4, QTextDocument, QStyle, \
|
QStyleOptionViewItemV4, QTextDocument, QStyle, \
|
||||||
QAbstractTextDocumentLayout, QPalette
|
QAbstractTextDocumentLayout, QPalette, QMessageBox
|
||||||
|
|
||||||
from weboob.core.ouiboube import Weboob
|
from weboob.core.ouiboube import Weboob
|
||||||
from weboob.core.scheduler import IScheduler
|
from weboob.core.scheduler import IScheduler
|
||||||
|
|
@ -105,8 +107,26 @@ class QtDo(QObject):
|
||||||
|
|
||||||
def default_eb(self, backend, error, backtrace):
|
def default_eb(self, backend, error, backtrace):
|
||||||
# TODO display a messagebox
|
# TODO display a messagebox
|
||||||
print error
|
msg = u'%s' % error
|
||||||
print backtrace
|
if logging.root.level == logging.DEBUG:
|
||||||
|
msg += '<br />'
|
||||||
|
ul_opened = False
|
||||||
|
for line in backtrace.split('\n'):
|
||||||
|
m = re.match(' File (.*)', line)
|
||||||
|
if m:
|
||||||
|
if not ul_opened:
|
||||||
|
msg += '<ul>'
|
||||||
|
ul_opened = True
|
||||||
|
else:
|
||||||
|
msg += '</li>'
|
||||||
|
msg += '<li><b>%s</b>' % m.group(1)
|
||||||
|
else:
|
||||||
|
msg += '<br />%s' % line
|
||||||
|
if ul_opened:
|
||||||
|
msg += '</li></ul>'
|
||||||
|
print >>sys.stderr, error
|
||||||
|
print >>sys.stderr, backtrace
|
||||||
|
QMessageBox.critical(None, self.tr('Error'), msg, QMessageBox.Ok)
|
||||||
|
|
||||||
def local_cb(self, backend, data):
|
def local_cb(self, backend, data):
|
||||||
self.cb(backend, data)
|
self.cb(backend, data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue