Salome HOME
Fix to allow Cleaner and SurfOpt to be launched on files with special characters...
[modules/smesh.git] / src / Tools / MGCleanerPlug / MGCleanerMonViewText.py
index 99e322d3111813d8c56f8c520653485f48c585e1..0271821e35f640bcaffabceb0f05649cd1493c0f 100644 (file)
@@ -67,33 +67,10 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
           PP.pprint([str(i) for i in sorted(self.monExe.processEnvironment().toStringList()) if 'DISTENE' in i])
         """
         
-        cmds = ''
-        ext = ''
-        if sys.platform == "win32":
-            if os.path.exists(self.parent().fichierOut):
-                cmds += 'del %s\n' % self.parent().fichierOut
-            ext = '.bat'
-        else:
-            cmds += '#!/bin/bash\n'
-            cmds += 'pwd\n'
-            #cmds += 'which mg-cleaner.exe\n'
-            cmds += 'echo "DISTENE_LICENSE_FILE="$DISTENE_LICENSE_FILE\n'
-            cmds += 'echo "DLIM8VAR="$DLIM8VAR\n'
-            cmds += 'rm -f %s\n' % self.parent().fichierOut
-            ext = '.bash'
-
-        cmds += 'echo %s\n' % txt #to see what is compute command
-        cmds += txt+'\n'
-        cmds += 'echo "END_OF_MGCleaner"\n'
-        
-        nomFichier = os.path.splitext(self.parent().fichierOut)[0] + ext
-        with open(nomFichier, 'w') as f:
-          f.write(cmds)
-        self.make_executable(nomFichier)
+        if os.path.exists(self.parent().fichierOut):
+            os.remove(self.parent().fichierOut)
         
-        if verbose: print(("INFO: MGCleaner launch script file: %s" % nomFichier))
-        
-        self.monExe.start(nomFichier)
+        self.monExe.start(txt)
         self.monExe.closeWriteChannel()
         self.enregistreResultatsDone=False
         self.show()
@@ -106,25 +83,25 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog):
     def saveFile(self):
         #recuperation du nom du fichier
         savedir=os.environ['HOME']
-        fn = QFileDialog.getSaveFileName(None, self.trUtf8("Save File"),savedir)
-        if fn.isNull() : return
+        fn, mask = QFileDialog.getSaveFileName(None,"Save File",savedir)
+        if not fn: return
         ulfile = os.path.abspath(str(fn))
         try:
-           f = open(fn, 'wb')
-           f.write(str(self.TB_Exe.toPlainText()))
-           f.close()
+            f = open(fn, 'wb')
+            f.write(self.TB_Exe.toPlainText().encode("utf-8"))
+            f.close()
         except IOError as why:
-           QMessageBox.critical(self, self.trUtf8('Save File'),
-                self.trUtf8('The file <b>%1</b> could not be saved.<br>Reason: %2')
-                    .arg(str(fn)).arg(str(why)))
+            QMessageBox.critical(self, 'Save File',
+                 'The file <b>%s</b> could not be saved.<br>Reason: %s'%(str(fn), str(why)))
 
     def readFromStdErr(self):
         a=self.monExe.readAllStandardError()
-        self.TB_Exe.append(str(a.data()))
+        aa=a.data().decode(errors='ignore')
+        self.TB_Exe.append(aa)
 
     def readFromStdOut(self) :
         a=self.monExe.readAllStandardOutput()
-        aa=str(a.data())
+        aa=a.data().decode(errors='ignore')
         self.TB_Exe.append(aa)
     
     def finished(self):