Salome HOME
Fix bugs with Cleaner and SurfOpt on Windows: cbr/fix_meshgems_plugins_for_windows
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 21 Sep 2016 15:31:37 +0000 (17:31 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 21 Sep 2016 15:31:37 +0000 (17:31 +0200)
- 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

src/Tools/MGCleanerPlug/MGCleanerMonViewText.py
src/Tools/YamsPlug/monViewText.py
src/Tools/YamsPlug/monYamsPlugDialog.py

index 86972fa312d667bb17aefbe8bbc85d0f7531909a..01c53069d800ac41fd37ef4e0ba6393f8e8ed5de 100644 (file)
@@ -57,6 +57,7 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
 
         self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
         self.monExe.readyReadStandardError.connect( self.readFromStdErr )
+        self.monExe.finished.connect( self.finished )
 
         """ for test set environment
         env = QProcessEnvironment().systemEnvironment()
@@ -69,7 +70,8 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
         cmds = ''
         ext = ''
         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:
             cmds += '#!/bin/bash\n'
@@ -124,10 +126,10 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
         a=self.monExe.readAllStandardOutput()
         aa=unicode(a.data())
         self.TB_Exe.append(aa)
-        if "END_OF_MGCleaner" in aa:
-          self.parent().enregistreResultat()
-          self.enregistreResultatsDone=True
-          #self.theClose()
+    
+    def finished(self):
+        self.parent().enregistreResultat()
+        self.enregistreResultatsDone=True
     
     def theClose(self):
       if not self.enregistreResultatsDone:
index 45115e68dfdcac3239f33184f93351e92fb1e196..c1e90255b6e7a8bd3704d0acc589401956a25875 100644 (file)
@@ -53,11 +53,14 @@ class MonViewText(Ui_ViewExe, QDialog):
 
         self.monExe.readyReadStandardOutput.connect( self.readFromStdOut )
         self.monExe.readyReadStandardError.connect( self.readFromStdErr )
+        self.monExe.finished.connect( self.finished )
       
         cmds = ''
         ext = ''
         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:
             cmds += '#!/bin/bash\n'
             cmds += 'pwd\n'
@@ -109,11 +112,11 @@ class MonViewText(Ui_ViewExe, QDialog):
     def readFromStdOut(self) :
         a=self.monExe.readAllStandardOutput()
         aa=unicode(a.data())
-        self.TB_Exe.append(aa)
-        if "END_OF_MGSurfOpt" in aa:
-          self.parent().enregistreResultat()
-          self.enregistreResultatsDone=True
-          #self.theClose()
+        self.TB_Exe.append(aa)    
+    
+    def finished(self):
+        self.parent().enregistreResultat()
+        self.enregistreResultatsDone=True
     
     def theClose(self):
       if not self.enregistreResultatsDone:
index 058fee9aa3e9cf52dc6f8913ce1c4420746be535..acd67c8728d029a5a9e6240c72c0f0bd424c3a22 100644 (file)
@@ -479,7 +479,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
     self.fichierIn=""
 
   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):
         os.remove(self.fichierIn)
     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
 
     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)
     if not self.RB_Absolute.isChecked():