From 3c8ed2e44eb3777cba3441934fac431e953fd691 Mon Sep 17 00:00:00 2001 From: marcel Date: Mon, 14 Aug 2017 11:29:32 +0200 Subject: [PATCH] [add] traceback for error in Thread --- pylot/core/util/thread.py | 12 +++++++----- pylot/core/util/widgets.py | 9 ++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pylot/core/util/thread.py b/pylot/core/util/thread.py index 65217a7f..5e79cb0e 100644 --- a/pylot/core/util/thread.py +++ b/pylot/core/util/thread.py @@ -67,9 +67,10 @@ class Thread(QThread): except Exception as e: self._executed = False self._executedError = e - exc_type, exc_obj, exc_tb = sys.exc_info() - fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] - print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno)) + traceback.print_exc() + exctype, value = sys.exc_info ()[:2] + self._executedErrorInfo = '{} {} {}'.\ + format(exctype, value, traceback.format_exc()) sys.stdout = sys.__stdout__ def showProgressbar(self): @@ -107,7 +108,7 @@ class Thread(QThread): class Worker(QRunnable): ''' - + Worker class to be run by MultiThread(QThread). ''' def __init__(self, fun, args, progressText=None, @@ -130,7 +131,7 @@ class Worker(QRunnable): try: result = self.fun(self.args) except: - traceback.print_exc() + #traceback.print_exc() exctype, value = sys.exc_info ()[:2] print(exctype, value, traceback.format_exc()) #self.signals.error.emit ((exctype, value, traceback.format_exc ())) @@ -148,6 +149,7 @@ class Worker(QRunnable): class WorkerSignals(QObject): ''' + Class to provide signals for Worker Class ''' finished = Signal(str) message = Signal(str) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index e5ce7950..7894312e 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -2342,8 +2342,10 @@ class TuneAutopicker(QWidget): def finish_picker(self): self.enable(True) if not self.ap_thread._executed: - self._warn('Could not execute picker:\n{}'.format( - self.ap_thread._executedError)) + msg = 'Could not execute picker:\n{}'.format( + self.ap_thread._executedError) + info = self.ap_thread._executedErrorInfo + self._warn(msg, info) return self.pylot_picks = self.ap_thread.data if not self.pylot_picks: @@ -2396,9 +2398,10 @@ class TuneAutopicker(QWidget): self.figure_tabs.setTabEnabled(2, bool) self.figure_tabs.setTabEnabled(3, bool) - def _warn(self, message): + def _warn(self, message, info=None): self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning, 'Warning', message) + self.qmb.setDetailedText(str(info)) self.qmb.show()