X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FYamsPlug%2FmonViewText.py;h=478e1833d0b0f4d46f3125283b552a6b65d163a2;hp=a613f5d6b893708d76e3dc7cff40155ed988c898;hb=0aa1e7419aa1b35b6096fd3aaf8dc559db3e28d0;hpb=c2dc77e7c1a0f512a5a0fa1117900df6c3c9dcb1 diff --git a/src/Tools/YamsPlug/monViewText.py b/src/Tools/YamsPlug/monViewText.py index a613f5d6b..478e1833d 100644 --- a/src/Tools/YamsPlug/monViewText.py +++ b/src/Tools/YamsPlug/monViewText.py @@ -1,10 +1,10 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 EDF R&D +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2015 EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,55 +22,50 @@ import string,types,os import traceback -from PyQt4 import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from qtsalome import * # Import des panels -# ------------------------------- # -from ViewText import Ui_ViewExe -class MonViewText(Ui_ViewExe,QDialog): -# ------------------------------- # +from ViewText_ui import Ui_ViewExe + +class MonViewText(Ui_ViewExe, QDialog): """ Classe permettant la visualisation de texte """ - def __init__(self,parent,txt): + def __init__(self, parent, txt): QDialog.__init__(self,parent) - self.pere=parent self.setupUi(self) - self.resize( QSize(600,600).expandedTo(self.minimumSizeHint()) ) - self.connect( self.PB_Ok,SIGNAL("clicked()"), self, SLOT("close()") ) - self.connect( self.PB_Save,SIGNAL("clicked()"), self.saveFile ) + self.resize( QSize(1000,600).expandedTo(self.minimumSizeHint()) ) + # self.PB_Ok.clicked.connect(self.close) + self.PB_Ok.clicked.connect( self.theClose ) + self.PB_Save.clicked.connect( self.saveFile ) self.monExe=QProcess(self) - - self.connect(self.monExe, SIGNAL("readyReadStandardOutput()"), self.readFromStdOut ) - self.connect(self.monExe, SIGNAL("readyReadStandardError()"), self.readFromStdErr ) - self.connect(self.monExe, SIGNAL("finished(int )"), self.exeFinished ) + self.monExe.readyReadStandardOutput.connect( self.readFromStdOut ) + self.monExe.readyReadStandardError.connect( self.readFromStdErr ) # Je n arrive pas a utiliser le setEnvironment du QProcess # fonctionne hors Salome mais pas dans Salome ??? - LICENCE=os.environ['DISTENE_LICENCE_FILE_FOR_YAMS'] - txt='export DISTENE_LICENSE_FILE='+LICENCE+';'+ txt + cmds='' + cmds+='rm -f '+self.parent().fichierOut+'\n' + cmds+=txt+'\n' + cmds+='echo END_OF_Yams\n' pid=self.monExe.pid() - nomFichier='/tmp/yam_'+str(pid)+'.py' + nomFichier='/tmp/Yams_'+str(pid)+'.sh' f=open(nomFichier,'w') - f.write(txt) + f.write(cmds) f.close() maBidouille='sh ' + nomFichier self.monExe.start(maBidouille) self.monExe.closeWriteChannel() + self.enregistreResultatsDone=False self.show() - def exeFinished(self): - self.pere.enregistreResultat() - def saveFile(self): #recuperation du nom du fichier savedir=os.environ['HOME'] - fn = QFileDialog.getSaveFileName(None, self.trUtf8("Save File"),savedir) + fn = QFileDialog.getSaveFileName(None,"Save File",savedir) if fn.isNull() : return ulfile = os.path.abspath(unicode(fn)) try: @@ -78,14 +73,24 @@ class MonViewText(Ui_ViewExe,QDialog): 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))) + QMessageBox.critical(self, 'Save File', + 'The file %1 could not be saved.
Reason: %2'%(unicode(fn), str(why))) def readFromStdErr(self): a=self.monExe.readAllStandardError() - self.TB_Exe.append(QString.fromUtf8(a.data(),len(a))) ; + self.TB_Exe.append(unicode(a.data().encode())) def readFromStdOut(self) : a=self.monExe.readAllStandardOutput() - self.TB_Exe.append(QString.fromUtf8(a.data(),len(a))) ; + aa=unicode(a.data(),len(a)) + self.TB_Exe.append(aa) + if "END_OF_Yams" in aa: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + #self.theClose() + + def theClose(self): + if not self.enregistreResultatsDone: + self.parent().enregistreResultat() + self.enregistreResultatsDone=True + self.close()