feature/port-to-py3 #11
14
PyLoT.py
14
PyLoT.py
@ -254,7 +254,7 @@ class MainWindow(QMainWindow):
|
|||||||
self._inputs.export2File(infile)
|
self._inputs.export2File(infile)
|
||||||
self.infile = infile
|
self.infile = infile
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self, use_logwidget=True):
|
||||||
try:
|
try:
|
||||||
self.startTime = min(
|
self.startTime = min(
|
||||||
[tr.stats.starttime for tr in self.data.wfdata])
|
[tr.stats.starttime for tr in self.data.wfdata])
|
||||||
@ -731,10 +731,14 @@ class MainWindow(QMainWindow):
|
|||||||
_widget.setLayout(self._main_layout)
|
_widget.setLayout(self._main_layout)
|
||||||
_widget.showFullScreen()
|
_widget.showFullScreen()
|
||||||
|
|
||||||
self.logwidget = LogWidget(parent=None)
|
if use_logwidget:
|
||||||
self.logwidget.show()
|
self.logwidget = LogWidget(parent=None)
|
||||||
sys.stdout = self.logwidget.stdout
|
self.logwidget.show()
|
||||||
sys.stderr = self.logwidget.stderr
|
self.stdout = self.logwidget.stdout
|
||||||
|
self.stderr = self.logwidget.stderr
|
||||||
|
|
||||||
|
sys.stdout = self.stdout
|
||||||
|
sys.stderr = self.stderr
|
||||||
|
|
||||||
self.setCentralWidget(_widget)
|
self.setCentralWidget(_widget)
|
||||||
|
|
||||||
|
@ -22,9 +22,11 @@ class Thread(QThread):
|
|||||||
self.abortButton = abortButton
|
self.abortButton = abortButton
|
||||||
self.finished.connect(self.hideProgressbar)
|
self.finished.connect(self.hideProgressbar)
|
||||||
self.showProgressbar()
|
self.showProgressbar()
|
||||||
|
self.old_stdout = None
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
|
self.old_stdout = sys.stdout
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
try:
|
try:
|
||||||
if self.arg is not None:
|
if self.arg is not None:
|
||||||
@ -39,7 +41,7 @@ class Thread(QThread):
|
|||||||
exctype, value = sys.exc_info()[:2]
|
exctype, value = sys.exc_info()[:2]
|
||||||
self._executedErrorInfo = '{} {} {}'. \
|
self._executedErrorInfo = '{} {} {}'. \
|
||||||
format(exctype, value, traceback.format_exc())
|
format(exctype, value, traceback.format_exc())
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def showProgressbar(self):
|
def showProgressbar(self):
|
||||||
if self.progressText:
|
if self.progressText:
|
||||||
@ -96,10 +98,12 @@ class Worker(QRunnable):
|
|||||||
self.progressText = progressText
|
self.progressText = progressText
|
||||||
self.pb_widget = pb_widget
|
self.pb_widget = pb_widget
|
||||||
self.redirect_stdout = redirect_stdout
|
self.redirect_stdout = redirect_stdout
|
||||||
|
self.old_stdout = None
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
|
self.old_stdout = sys.stdout
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -112,7 +116,7 @@ class Worker(QRunnable):
|
|||||||
self.signals.result.emit(result)
|
self.signals.result.emit(result)
|
||||||
finally:
|
finally:
|
||||||
self.signals.finished.emit('Done')
|
self.signals.finished.emit('Done')
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def write(self, text):
|
def write(self, text):
|
||||||
self.signals.message.emit(text)
|
self.signals.message.emit(text)
|
||||||
@ -144,11 +148,13 @@ class MultiThread(QThread):
|
|||||||
self.progressText = progressText
|
self.progressText = progressText
|
||||||
self.pb_widget = pb_widget
|
self.pb_widget = pb_widget
|
||||||
self.redirect_stdout = redirect_stdout
|
self.redirect_stdout = redirect_stdout
|
||||||
|
self.old_stdout = None
|
||||||
self.finished.connect(self.hideProgressbar)
|
self.finished.connect(self.hideProgressbar)
|
||||||
self.showProgressbar()
|
self.showProgressbar()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.redirect_stdout:
|
if self.redirect_stdout:
|
||||||
|
self.old_stdout = sys.stdout
|
||||||
sys.stdout = self
|
sys.stdout = self
|
||||||
try:
|
try:
|
||||||
if not self.ncores:
|
if not self.ncores:
|
||||||
@ -164,7 +170,7 @@ class MultiThread(QThread):
|
|||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
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))
|
print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno))
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = self.old_stdout
|
||||||
|
|
||||||
def showProgressbar(self):
|
def showProgressbar(self):
|
||||||
if self.progressText:
|
if self.progressText:
|
||||||
|
Loading…
Reference in New Issue
Block a user