X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FYamsPlug%2FmonViewText.py;h=9d92a0c55a7eac476d31cc47d38bc3f10d865d62;hp=c1e90255b6e7a8bd3704d0acc589401956a25875;hb=a38b958b273ded56f74a783859e0781aa49e8787;hpb=a1920ff31054e2c882bd94d4f3c04abe53980ce0 diff --git a/src/Tools/YamsPlug/monViewText.py b/src/Tools/YamsPlug/monViewText.py index c1e90255b..9d92a0c55 100644 --- a/src/Tools/YamsPlug/monViewText.py +++ b/src/Tools/YamsPlug/monViewText.py @@ -35,8 +35,8 @@ verbose = True force = os.getenv("FORCE_DISTENE_LICENSE_FILE") if force != None: - os.environ["DISTENE_LICENSE_FILE"] = force - os.environ["DLIM8VAR"] = "NOTHING" + os.environ["DISTENE_LICENSE_FILE"] = force + os.environ["DLIM8VAR"] = "NOTHING" class MonViewText(Ui_ViewExe, QDialog): """ @@ -54,7 +54,7 @@ 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": @@ -73,14 +73,14 @@ class MonViewText(Ui_ViewExe, QDialog): cmds += 'echo %s\n' % txt #to see what is compute command cmds += txt+'\n' cmds += 'echo "END_OF_MGSurfOpt"\n' - + nomFichier = os.path.splitext(self.parent().fichierOut)[0] + ext with open(nomFichier, 'w') as f: - f.write(cmds) + f.write(cmds) self.make_executable(nomFichier) - - if verbose: print("INFO: MGSurfOpt launch script file: %s" % nomFichier) - + + if verbose: print(("INFO: MGSurfOpt launch script file: %s" % nomFichier)) + self.monExe.start(nomFichier) self.monExe.closeWriteChannel() self.enregistreResultatsDone=False @@ -94,32 +94,33 @@ class MonViewText(Ui_ViewExe, QDialog): def saveFile(self): #recuperation du nom du fichier savedir=os.environ['HOME'] - fn = QFileDialog.getSaveFileName(None,"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, 'Save File', - 'The file %1 could not be saved.
Reason: %2'%(unicode(fn), 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().encode())) + aa=a.data().decode(errors='ignore') + self.TB_Exe.append(aa) def readFromStdOut(self) : a=self.monExe.readAllStandardOutput() - aa=unicode(a.data()) - self.TB_Exe.append(aa) - + aa=a.data().decode(errors='ignore') + self.TB_Exe.append(aa) + def finished(self): self.parent().enregistreResultat() self.enregistreResultatsDone=True - + def theClose(self): - if not self.enregistreResultatsDone: - self.parent().enregistreResultat() - self.enregistreResultatsDone=True - self.close() + if not self.enregistreResultatsDone: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + self.close()