Fix bugs with Cleaner and SurfOpt on Windows:

- the generated .bat had a delete command instead of del
- using .meshb does not work on Windows, we use .mesh instead
- the result file was sometimes imported twice because the signal readyReadStandardOutput was sometimes emited twice
This commit is contained in:
Christophe Bourcier 2016-09-21 17:31:37 +02:00
parent b9c863fcfc
commit e0a628e580
3 changed files with 18 additions and 13 deletions

View File

@ -57,6 +57,7 @@ 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 )
""" for test set environment """ for test set environment
env = QProcessEnvironment().systemEnvironment() env = QProcessEnvironment().systemEnvironment()
@ -69,7 +70,8 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
cmds = '' cmds = ''
ext = '' ext = ''
if sys.platform == "win32": if sys.platform == "win32":
cmds += 'delete %s\n' % self.parent().fichierOut if os.path.exists(self.parent().fichierOut):
cmds += 'del %s\n' % self.parent().fichierOut
ext = '.bat' ext = '.bat'
else: else:
cmds += '#!/bin/bash\n' cmds += '#!/bin/bash\n'
@ -124,10 +126,10 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
a=self.monExe.readAllStandardOutput() a=self.monExe.readAllStandardOutput()
aa=unicode(a.data()) aa=unicode(a.data())
self.TB_Exe.append(aa) self.TB_Exe.append(aa)
if "END_OF_MGCleaner" in aa:
def finished(self):
self.parent().enregistreResultat() self.parent().enregistreResultat()
self.enregistreResultatsDone=True self.enregistreResultatsDone=True
#self.theClose()
def theClose(self): def theClose(self):
if not self.enregistreResultatsDone: if not self.enregistreResultatsDone:

View File

@ -53,11 +53,14 @@ class MonViewText(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 )
cmds = '' cmds = ''
ext = '' ext = ''
if sys.platform == "win32": if sys.platform == "win32":
cmds += 'delete %s\n' % self.parent().fichierOut if os.path.exists(self.parent().fichierOut):
cmds += 'del %s\n' % self.parent().fichierOut
ext = '.bat'
else: else:
cmds += '#!/bin/bash\n' cmds += '#!/bin/bash\n'
cmds += 'pwd\n' cmds += 'pwd\n'
@ -110,10 +113,10 @@ class MonViewText(Ui_ViewExe, QDialog):
a=self.monExe.readAllStandardOutput() a=self.monExe.readAllStandardOutput()
aa=unicode(a.data()) aa=unicode(a.data())
self.TB_Exe.append(aa) self.TB_Exe.append(aa)
if "END_OF_MGSurfOpt" in aa:
def finished(self):
self.parent().enregistreResultat() self.parent().enregistreResultat()
self.enregistreResultatsDone=True self.enregistreResultatsDone=True
#self.theClose()
def theClose(self): def theClose(self):
if not self.enregistreResultatsDone: if not self.enregistreResultatsDone:

View File

@ -479,7 +479,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
self.fichierIn="" self.fichierIn=""
def prepareFichier(self): def prepareFichier(self):
self.fichierIn=tempfile.mktemp(suffix=".meshb",prefix="ForSurfOpt_") self.fichierIn=tempfile.mktemp(suffix=".mesh",prefix="ForSurfOpt_")
if os.path.exists(self.fichierIn): if os.path.exists(self.fichierIn):
os.remove(self.fichierIn) os.remove(self.fichierIn)
self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True) self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True)
@ -522,7 +522,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
self.commande+= " -O G" # This option has not been updated to the new option style yet self.commande+= " -O G" # This option has not been updated to the new option style yet
deb=os.path.splitext(self.fichierIn) deb=os.path.splitext(self.fichierIn)
self.fichierOut=deb[0] + "_output.meshb" self.fichierOut=deb[0] + "_output.mesh"
tolerance=self.SP_toStr(self.SP_Tolerance) tolerance=self.SP_toStr(self.SP_Tolerance)
if not self.RB_Absolute.isChecked(): if not self.RB_Absolute.isChecked():