X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2FYamsPlug%2FmonViewText.py;h=3109bfe8aad4c8ac3de005f910636ea4d3712bfb;hb=5260bd00bd51567f6137d5ea7ae0564464c4290a;hp=426467ef4351d3380656ef528ee70de52fc34016;hpb=0f0bf7c72871fc015ec1637067cd1d58e61395b9;p=modules%2Fsmesh.git
diff --git a/src/Tools/YamsPlug/monViewText.py b/src/Tools/YamsPlug/monViewText.py
index 426467ef4..3109bfe8a 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):
"""
@@ -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'
@@ -70,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
@@ -93,30 +96,30 @@ class MonViewText(Ui_ViewExe, QDialog):
savedir=os.environ['HOME']
fn = QFileDialog.getSaveFileName(None,"Save File",savedir)
if fn.isNull() : return
- ulfile = os.path.abspath(unicode(fn))
+ 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(str(self.TB_Exe.toPlainText()))
+ f.close()
+ except IOError as why:
+ QMessageBox.critical(self, 'Save File',
+ 'The file %1 could not be saved.
Reason: %2'%(str(fn), str(why)))
def readFromStdErr(self):
a=self.monExe.readAllStandardError()
- self.TB_Exe.append(unicode(a.data().encode()))
+ self.TB_Exe.append(str(a.data().encode()))
def readFromStdOut(self) :
a=self.monExe.readAllStandardOutput()
- aa=unicode(a.data(),len(a))
+ aa=str(a.data())
self.TB_Exe.append(aa)
- if "END_OF_MGSurfOpt" in aa:
- self.parent().enregistreResultat()
- self.enregistreResultatsDone=True
- #self.theClose()
-
- def theClose(self):
- if not self.enregistreResultatsDone:
+
+ def finished(self):
self.parent().enregistreResultat()
self.enregistreResultatsDone=True
- self.close()
+
+ def theClose(self):
+ if not self.enregistreResultatsDone:
+ self.parent().enregistreResultat()
+ self.enregistreResultatsDone=True
+ self.close()