X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2FMGCleanerPlug%2FMGCleanerMonViewText.py;h=0271821e35f640bcaffabceb0f05649cd1493c0f;hb=6d3cec2c3838c5e4742b93f04d43733a0c3b08f9;hp=01c53069d800ac41fd37ef4e0ba6393f8e8ed5de;hpb=e0a628e580a7affa81c44ea1dacc584c29fc82dc;p=modules%2Fsmesh.git diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py index 01c53069d..0271821e3 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py @@ -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 - ulfile = os.path.abspath(unicode(fn)) + 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() - except IOError, why: - QMessageBox.critical(self, self.trUtf8('Save File'), - self.trUtf8('The file %1 could not be saved.
Reason: %2') - .arg(unicode(fn)).arg(str(why))) + f = open(fn, 'wb') + f.write(self.TB_Exe.toPlainText().encode("utf-8")) + f.close() + except IOError as why: + QMessageBox.critical(self, 'Save File', + 'The file %s could not be saved.
Reason: %s'%(str(fn), str(why))) def readFromStdErr(self): a=self.monExe.readAllStandardError() - self.TB_Exe.append(unicode(a.data())) + aa=a.data().decode(errors='ignore') + self.TB_Exe.append(aa) def readFromStdOut(self) : a=self.monExe.readAllStandardOutput() - aa=unicode(a.data()) + aa=a.data().decode(errors='ignore') self.TB_Exe.append(aa) def finished(self):