Merge branch 'develop' of ariadne.geophysik.rub.de:/data/git/pylot into develop
Conflicts: pylot/RELEASE-VERSION
This commit is contained in:
@@ -1 +0,0 @@
|
||||
4244c-dirty
|
||||
@@ -107,7 +107,7 @@ class PylotParameter(object):
|
||||
yield key, value
|
||||
|
||||
def hasParam(self, parameter):
|
||||
if self.__parameter.has_key(parameter):
|
||||
if parameter in self.__parameter.keys():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys, os
|
||||
import multiprocessing
|
||||
from PySide.QtCore import QThread, Signal, Qt
|
||||
from PySide.QtGui import QDialog, QProgressBar, QLabel, QHBoxLayout
|
||||
from PySide.QtGui import QDialog, QProgressBar, QLabel, QHBoxLayout, QPushButton
|
||||
|
||||
|
||||
class AutoPickThread(QThread):
|
||||
@@ -69,6 +70,76 @@ class Thread(QThread):
|
||||
print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno))
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
# def __del__(self):
|
||||
# self.wait()
|
||||
|
||||
def showProgressbar(self):
|
||||
if self.progressText:
|
||||
|
||||
# generate widget if not given in init
|
||||
if not self.pb_widget:
|
||||
self.pb_widget = QDialog(self.parent())
|
||||
self.pb_widget.setWindowFlags(Qt.SplashScreen)
|
||||
self.pb_widget.setModal(True)
|
||||
|
||||
# add button
|
||||
delete_button = QPushButton('X')
|
||||
delete_button.clicked.connect(self.exit)
|
||||
hl = QHBoxLayout()
|
||||
pb = QProgressBar()
|
||||
pb.setRange(0, 0)
|
||||
hl.addWidget(pb)
|
||||
hl.addWidget(QLabel(self.progressText))
|
||||
hl.addWidget(delete_button)
|
||||
self.pb_widget.setLayout(hl)
|
||||
self.pb_widget.show()
|
||||
|
||||
def hideProgressbar(self):
|
||||
if self.pb_widget:
|
||||
self.pb_widget.hide()
|
||||
|
||||
def write(self, text):
|
||||
self.message.emit(text)
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
|
||||
class MultiThread(QThread):
|
||||
finished = Signal(str)
|
||||
message = Signal(str)
|
||||
|
||||
def __init__(self, parent, func, args, ncores=0,
|
||||
progressText=None, pb_widget=None, redirect_stdout=False):
|
||||
QThread.__init__(self, parent)
|
||||
self.func = func
|
||||
self.args = args
|
||||
self.ncores = ncores
|
||||
self.progressText = progressText
|
||||
self.pb_widget = pb_widget
|
||||
self.redirect_stdout = redirect_stdout
|
||||
self.finished.connect(self.hideProgressbar)
|
||||
self.showProgressbar()
|
||||
|
||||
def run(self):
|
||||
# if self.redirect_stdout:
|
||||
# sys.stdout = self
|
||||
# #try:
|
||||
if not self.ncores:
|
||||
self.ncores = multiprocessing.cpu_count()
|
||||
pool = multiprocessing.Pool(self.ncores)
|
||||
self.data = pool.map_async(self.func, self.args, callback=self.emitDone)
|
||||
#self.data = pool.apply_async(self.func, self.shotlist, callback=self.emitDone) #emit each time returned
|
||||
pool.close()
|
||||
self._executed = True
|
||||
# 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))
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
def __del__(self):
|
||||
self.wait()
|
||||
|
||||
@@ -96,3 +167,7 @@ class Thread(QThread):
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
def emitDone(self, result):
|
||||
print('emitDone!')
|
||||
self.finished.emit('Done thread!')
|
||||
self.hideProgressbar()
|
||||
|
||||
Reference in New Issue
Block a user