[reformat] code reformatting with PyCharm
This commit is contained in:
1 parent
4107f0249d
commit
20b31a1c5c
49 files changed
+3255
-3194
No files matched your search
+18
-14
@@ -1,6 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys, os, traceback
|
||||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from PySide.QtCore import QThread, Signal, Qt, Slot, QRunnable, QObject
|
||||
from PySide.QtGui import QDialog, QProgressBar, QLabel, QHBoxLayout, QPushButton
|
||||
|
||||
@@ -42,7 +45,7 @@ class AutoPickThread(QThread):
|
||||
|
||||
class Thread(QThread):
|
||||
message = Signal(str)
|
||||
|
||||
|
||||
def __init__(self, parent, func, arg=None, progressText=None, pb_widget=None, redirect_stdout=False):
|
||||
QThread.__init__(self, parent)
|
||||
self.func = func
|
||||
@@ -55,7 +58,7 @@ class Thread(QThread):
|
||||
|
||||
def run(self):
|
||||
if self.redirect_stdout:
|
||||
sys.stdout = self
|
||||
sys.stdout = self
|
||||
try:
|
||||
if self.arg:
|
||||
self.data = self.func(self.arg)
|
||||
@@ -68,7 +71,7 @@ class Thread(QThread):
|
||||
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__
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
def __del__(self):
|
||||
self.wait()
|
||||
@@ -79,7 +82,7 @@ class Thread(QThread):
|
||||
# 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.setWindowFlags(Qt.SplashScreen)
|
||||
self.pb_widget.setModal(True)
|
||||
|
||||
# add button
|
||||
@@ -109,6 +112,7 @@ class Worker(QRunnable):
|
||||
'''
|
||||
|
||||
'''
|
||||
|
||||
def __init__(self, fun, args,
|
||||
progressText=None,
|
||||
pb_widget=None,
|
||||
@@ -116,7 +120,7 @@ class Worker(QRunnable):
|
||||
super(Worker, self).__init__()
|
||||
self.fun = fun
|
||||
self.args = args
|
||||
#self.kwargs = kwargs
|
||||
# self.kwargs = kwargs
|
||||
self.signals = WorkerSignals()
|
||||
self.progressText = progressText
|
||||
self.pb_widget = pb_widget
|
||||
@@ -131,9 +135,9 @@ class Worker(QRunnable):
|
||||
result = self.fun(self.args)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
exctype, value = sys.exc_info ()[:2]
|
||||
exctype, value = sys.exc_info()[:2]
|
||||
print(exctype, value, traceback.format_exc())
|
||||
#self.signals.error.emit ((exctype, value, traceback.format_exc ()))
|
||||
# self.signals.error.emit ((exctype, value, traceback.format_exc ()))
|
||||
else:
|
||||
self.signals.result.emit(result)
|
||||
finally:
|
||||
@@ -157,7 +161,7 @@ class WorkerSignals(QObject):
|
||||
|
||||
class MultiThread(QThread):
|
||||
finished = Signal(str)
|
||||
message = Signal(str)
|
||||
message = Signal(str)
|
||||
|
||||
def __init__(self, parent, func, args, ncores=1,
|
||||
progressText=None, pb_widget=None, redirect_stdout=False):
|
||||
@@ -170,16 +174,16 @@ class MultiThread(QThread):
|
||||
self.redirect_stdout = redirect_stdout
|
||||
self.finished.connect(self.hideProgressbar)
|
||||
self.showProgressbar()
|
||||
|
||||
|
||||
def run(self):
|
||||
if self.redirect_stdout:
|
||||
sys.stdout = self
|
||||
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
|
||||
# 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:
|
||||
@@ -188,7 +192,7 @@ class MultiThread(QThread):
|
||||
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__
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
def __del__(self):
|
||||
self.wait()
|
||||
@@ -197,7 +201,7 @@ class MultiThread(QThread):
|
||||
if self.progressText:
|
||||
if not self.pb_widget:
|
||||
self.pb_widget = QDialog(self.parent())
|
||||
self.pb_widget.setWindowFlags(Qt.SplashScreen)
|
||||
self.pb_widget.setWindowFlags(Qt.SplashScreen)
|
||||
self.pb_widget.setModal(True)
|
||||
hl = QHBoxLayout()
|
||||
pb = QProgressBar()
|
||||
|
||||
Reference in new issue
Block a user