mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-12 00:29:17 +05:00
Improve behaviour of Cleaner and SurfOpt in case of error and add a cancel button.
This commit is contained in:
parent
c9afb20072
commit
47242d5934
@ -44,12 +44,17 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
|
|||||||
"""
|
"""
|
||||||
Classe permettant la visualisation de texte
|
Classe permettant la visualisation de texte
|
||||||
"""
|
"""
|
||||||
def __init__(self, parent, txt, ):
|
def __init__(self, parent, txt):
|
||||||
QDialog.__init__(self,parent)
|
QDialog.__init__(self,parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) )
|
self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) )
|
||||||
#self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") )
|
|
||||||
self.PB_Ok.clicked.connect( self.theClose )
|
self.PB_Ok.clicked.connect( self.theClose )
|
||||||
|
# Button OK is disabled until computation is finished
|
||||||
|
self.PB_Ok.setEnabled(False)
|
||||||
|
# Button cancel allows to kill the computation
|
||||||
|
# It is disabled when the computation is finished
|
||||||
|
self.PB_Cancel.clicked.connect( self.cancelComputation )
|
||||||
|
self.PB_Cancel.setToolTip("Cancel computation")
|
||||||
self.PB_Save.clicked.connect( self.saveFile )
|
self.PB_Save.clicked.connect( self.saveFile )
|
||||||
self.PB_Save.setToolTip("Save trace in log file")
|
self.PB_Save.setToolTip("Save trace in log file")
|
||||||
self.PB_Ok.setToolTip("Close view")
|
self.PB_Ok.setToolTip("Close view")
|
||||||
@ -58,21 +63,15 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
|
|||||||
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
||||||
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
||||||
self.monExe.finished.connect( self.finished )
|
self.monExe.finished.connect( self.finished )
|
||||||
|
self.monExe.errorOccurred.connect( self.errorOccured )
|
||||||
""" for test set environment
|
|
||||||
env = QProcessEnvironment().systemEnvironment()
|
|
||||||
env.insert("HELLO", "bonjour") #Add an environment variable for debug
|
|
||||||
self.monExe.setProcessEnvironment(env)
|
|
||||||
if verbose:
|
|
||||||
PP.pprint([str(i) for i in sorted(self.monExe.processEnvironment().toStringList()) if 'DISTENE' in i])
|
|
||||||
"""
|
|
||||||
|
|
||||||
if os.path.exists(self.parent().fichierOut):
|
if os.path.exists(self.parent().fichierOut):
|
||||||
os.remove(self.parent().fichierOut)
|
os.remove(self.parent().fichierOut)
|
||||||
|
|
||||||
self.monExe.start(txt)
|
self.monExe.start(txt)
|
||||||
self.monExe.closeWriteChannel()
|
self.monExe.closeWriteChannel()
|
||||||
self.enregistreResultatsDone=False
|
self.hasBeenCanceled = False
|
||||||
|
self.anErrorOccured = False
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def make_executable(self, path):
|
def make_executable(self, path):
|
||||||
@ -105,11 +104,24 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
|
|||||||
self.TB_Exe.append(aa)
|
self.TB_Exe.append(aa)
|
||||||
|
|
||||||
def finished(self):
|
def finished(self):
|
||||||
|
self.PB_Ok.setEnabled(True)
|
||||||
|
self.PB_Cancel.setEnabled(False)
|
||||||
|
exit_code = self.monExe.exitCode()
|
||||||
|
if exit_code == 0 and not self.anErrorOccured:
|
||||||
self.parent().enregistreResultat()
|
self.parent().enregistreResultat()
|
||||||
self.enregistreResultatsDone=True
|
elif not self.hasBeenCanceled:
|
||||||
|
QMessageBox.critical(self, 'Computation failed',
|
||||||
|
'The computation has failed.<br>Please, check the log message.')
|
||||||
|
pass
|
||||||
|
|
||||||
|
def errorOccured(self):
|
||||||
|
# for instance if the executable is not found
|
||||||
|
self.anErrorOccured = True
|
||||||
|
self.finished()
|
||||||
|
|
||||||
|
def cancelComputation(self):
|
||||||
|
self.hasBeenCanceled = True
|
||||||
|
self.monExe.kill()
|
||||||
|
|
||||||
def theClose(self):
|
def theClose(self):
|
||||||
if not self.enregistreResultatsDone:
|
|
||||||
self.parent().enregistreResultat()
|
|
||||||
self.enregistreResultatsDone=True
|
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<string>Run MGCleaner</string>
|
<string>Run MGCleaner</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QTextBrowser" name="TB_Exe"/>
|
<widget class="QTextBrowser" name="TB_Exe"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
@ -25,9 +25,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="PB_Cancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
<widget class="QPushButton" name="PB_Save">
|
<widget class="QPushButton" name="PB_Save">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Save log</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Run Yams</string>
|
<string>Run MGCleaner</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QTextBrowser" name="TB_Exe"/>
|
<widget class="QTextBrowser" name="TB_Exe"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
@ -25,9 +25,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="PB_Cancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
<widget class="QPushButton" name="PB_Save">
|
<widget class="QPushButton" name="PB_Save">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Save log</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -29,6 +29,7 @@ import pprint as PP #pretty print
|
|||||||
from qtsalome import *
|
from qtsalome import *
|
||||||
|
|
||||||
# Import des panels
|
# Import des panels
|
||||||
|
|
||||||
from ViewText_ui import Ui_ViewExe
|
from ViewText_ui import Ui_ViewExe
|
||||||
|
|
||||||
verbose = True
|
verbose = True
|
||||||
@ -46,21 +47,30 @@ class MonViewText(Ui_ViewExe, QDialog):
|
|||||||
QDialog.__init__(self,parent)
|
QDialog.__init__(self,parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) )
|
self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) )
|
||||||
# self.PB_Ok.clicked.connect(self.close)
|
|
||||||
self.PB_Ok.clicked.connect( self.theClose )
|
self.PB_Ok.clicked.connect( self.theClose )
|
||||||
|
# Button OK is disabled until computation is finished
|
||||||
|
self.PB_Ok.setEnabled(False)
|
||||||
|
# Button cancel allows to kill the computation
|
||||||
|
# It is disabled when the computation is finished
|
||||||
|
self.PB_Cancel.clicked.connect( self.cancelComputation )
|
||||||
|
self.PB_Cancel.setToolTip("Cancel computation")
|
||||||
self.PB_Save.clicked.connect( self.saveFile )
|
self.PB_Save.clicked.connect( self.saveFile )
|
||||||
|
self.PB_Save.setToolTip("Save trace in log file")
|
||||||
|
self.PB_Ok.setToolTip("Close view")
|
||||||
self.monExe=QProcess(self)
|
self.monExe=QProcess(self)
|
||||||
|
|
||||||
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
|
||||||
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
self.monExe.readyReadStandardError.connect( self.readFromStdErr )
|
||||||
self.monExe.finished.connect( self.finished )
|
self.monExe.finished.connect( self.finished )
|
||||||
|
self.monExe.errorOccurred.connect( self.errorOccured )
|
||||||
|
|
||||||
if os.path.exists(self.parent().fichierOut):
|
if os.path.exists(self.parent().fichierOut):
|
||||||
os.remove(self.parent().fichierOut)
|
os.remove(self.parent().fichierOut)
|
||||||
|
|
||||||
self.monExe.start(txt)
|
self.monExe.start(txt)
|
||||||
self.monExe.closeWriteChannel()
|
self.monExe.closeWriteChannel()
|
||||||
self.enregistreResultatsDone=False
|
self.hasBeenCanceled = False
|
||||||
|
self.anErrorOccured = False
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def make_executable(self, path):
|
def make_executable(self, path):
|
||||||
@ -93,11 +103,24 @@ class MonViewText(Ui_ViewExe, QDialog):
|
|||||||
self.TB_Exe.append(aa)
|
self.TB_Exe.append(aa)
|
||||||
|
|
||||||
def finished(self):
|
def finished(self):
|
||||||
|
self.PB_Ok.setEnabled(True)
|
||||||
|
self.PB_Cancel.setEnabled(False)
|
||||||
|
exit_code = self.monExe.exitCode()
|
||||||
|
if exit_code == 0 and not self.anErrorOccured:
|
||||||
self.parent().enregistreResultat()
|
self.parent().enregistreResultat()
|
||||||
self.enregistreResultatsDone=True
|
elif not self.hasBeenCanceled:
|
||||||
|
QMessageBox.critical(self, 'Computation failed',
|
||||||
|
'The computation has failed.<br>Please, check the log message.')
|
||||||
|
pass
|
||||||
|
|
||||||
|
def errorOccured(self):
|
||||||
|
# for instance if the executable is not found
|
||||||
|
self.anErrorOccured = True
|
||||||
|
self.finished()
|
||||||
|
|
||||||
|
def cancelComputation(self):
|
||||||
|
self.hasBeenCanceled = True
|
||||||
|
self.monExe.kill()
|
||||||
|
|
||||||
def theClose(self):
|
def theClose(self):
|
||||||
if not self.enregistreResultatsDone:
|
|
||||||
self.parent().enregistreResultat()
|
|
||||||
self.enregistreResultatsDone=True
|
|
||||||
self.close()
|
self.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user