from PyQt4.QtGui import *
from PyQt4.QtCore import *
import time
+import pdb
from datetime import date
from Extensions.i18n import tr
from Editeur import Objecttreeitem
from desBaseWidget import Ui_baseWidget
from monViewTexte import ViewText
+from monViewTexte import ViewText2
+from monWidgetCreeParam import MonWidgetCreeParam
import browser
import readercata
QtGui.QWidget.__init__(self,None)
self.setupUi(self)
- self.monOptionnel=None
+ self.widgetOptionnel=None
self.fenetreCentraleAffichee=None
+ self.dejaDansPlieTout=False
+ self.afficheCommandesPliees = True
self.appliEficas = appli
self.appli = appli #---- attendu par IHM
self.vm = vm
# ces attributs sont mis a jour par definitCode appelee par newEditor
self.code = self.appliEficas.CONFIGURATION.code
- self.affiche_alpha=1
- if self.code in ['MAP','Adao'] :
+ self.mode_nouv_commande=self.appliEficas.CONFIGURATION.mode_nouv_commande
+ self.affiche=self.appliEficas.CONFIGURATION.affiche
+ #if self.code in ['MAP','CARMELCND','PSEN'] : self.afficheCommandesPliees=False
+ if self.code in ['MAP','CARMELCND'] : self.afficheCommandesPliees=False
+ if self.code in ['MAP',] :
self.widgetTree.close()
self.widgetTree=None
self.appliEficas.resize(1440,self.appliEficas.height())
self.readercata=self.appliEficas.readercata
if self.readercata.fic_cata == None : return #Sortie Salome
self.titre=self.readercata.titre
+ self.Ordre_Des_Commandes=self.readercata.Ordre_Des_Commandes
+ self.Classement_Commandes_Ds_Arbre=self.readercata.Classement_Commandes_Ds_Arbre
self.format = self.appliEficas.format_fichier
self.node_selected = []
self.deplier = True
self.message=''
+ if self.code in ['Adao','MAP'] : self.afficheApresInsert=True
+ else : self.afficheApresInsert=False
+ if self.code in ['TELEMAC',] : self.enteteQTree='premier'
+ else : self.enteteQTree='complet'
+ if self.code in ['Adao','TELEMAC'] : self.affichePlie=True
+ else : self.affichePlie=False
self.Commandes_Ordre_Catalogue =self.readercata.Commandes_Ordre_Catalogue
#------- construction du jdc --------------
jdc_item = None
- self.mode_nouv_commande=self.readercata.mode_nouv_commande
self.nouveau=0
if self.fichier is not None: # fichier jdc fourni
self.fileInfo = QFileInfo(self.fichier)
self.fileInfo.setCaching(0)
if jdc==None :
- try :
+ # try :
+ if 1:
self.jdc = self.readFile(self.fichier)
- except :
+ #except :
+ else :
print "mauvaise lecture"
else :
self.jdc=jdc
if self.jdc:
self.jdc.appli = self
self.jdc.lang = self.appli.langue
- print self.jdc.lang
+ self.jdc.aReafficher=False
txt_exception = None
if not jdc:
self.jdc.analyse()
jdc_item=Objecttreeitem.make_objecttreeitem( self, "nom", self.jdc )
if (not self.jdc.isvalid()) and (not self.nouveau) and (self.appliEficas.ssIhm == False):
self.viewJdcRapport()
+
+
if jdc_item:
self.tree = browser.JDCTree( jdc_item, self )
self.appliEficas.construitMenu()
+ #-------------------# Pour execution avec output sans une fenetre EFICAS. (erreurs encore dans la fenetre bash)
+ def runPSEN_2(self):
+ #-------------------#
+ if self.modified or self.fichier==None :
+ QMessageBox.critical( self, tr( "Execution impossible "),tr("Sauvegarder SVP avant l'execution "))
+ return
+
+ #monPython="/home/A96028/salome75/prerequisites/install/Python-273-tcl8513-tk8513/bin/python"
+ #monWrapper="/local00/home/A96028/GitEficasTravail/eficas/PSEN_Eficas/PSSEWrapper.py"
+ path1 = os.path.abspath(os.path.join(os.path.abspath(__file__), '../','../','PSEN_Eficas','PSEN'))
+ monWrapper = os.path.join(path1, 'PSSEWrapper.py')
+ cmd=['python',monWrapper]
+
+ w = ViewText2( self.QWParent, cmd )
+ w.setWindowTitle( "execution" )
+ w.exec_()
+
+
+ #-------------------# Pour execution avec output et error dans le bash
+ def runPSEN(self):
+ #-------------------#
+ if self.modified or self.fichier==None : self.saveFile()
+
+ #lancement avec le .bat
+ path1 = os.path.abspath(os.path.join(os.path.abspath(__file__), '../','../','PSEN_Eficas','PSEN'))
+ WrapperFilePath = os.path.join(path1, 'PSSEWrapper.py')
+ import subprocess
+ p = subprocess.Popen(['python',WrapperFilePath])
+ (out,err)=p.communicate()
+ print out
+ print err
+
#--------------------------------#
def _newJDC( self ,units = None):
#--------------------------------#
texte=""
if self.code == "CARMELCND" : texte=self._newJDCCND()
if self.code == "ZCRACKS" : texte=self._newZCRACKS()
+ if self.code == "TELEMAC" : texte=self._newTELEMAC()
+ if self.code == "PSEN" : texte = self._newPSEN()
# texte=self.newTexteCND
jdc=self.readercata.cata[0].JdC( procedure =texte,
QMessageBox.critical( self, tr("Type de fichier non reconnu"),tr("EFICAS ne sait pas ouvrir ce type de fichier"))
return None
- #----------------------------------------------#
- def _viewText(self, txt, caption = "FILE_VIEWER"):
- #----------------------------------------------#
- w = ViewText( self.QWParent )
- w.setWindowTitle( caption )
- w.setText(txt)
+ #-----------------------------------------------------------------------#
+ def _viewText(self, txt, caption = "FILE_VIEWER",largeur=1200,hauteur=600):
+ #--------------------------------------------------------------------#
+ w = ViewText( self.QWParent,self ,caption,txt,largeur,hauteur)
w.show()
#
f.close()
self.connect(self.monExe, SIGNAL("readyReadStandardOutput()"), self.readFromStdOut )
self.connect(self.monExe, SIGNAL("readyReadStandardError()"), self.readFromStdErr )
- exe='sh /tmp/test.sh'
+ exe='sh ' + nomFichier
self.monExe.start(exe)
self.monExe.closeWriteChannel()
self.w.exec_()
+ #-----------------------#
+ def gestionParam(self):
+ #-----------------------#
+ w = MonWidgetCreeParam( self)
+ w.show()
+
#-----------------------#
def viewJdcSource(self):
#-----------------------#
def viewJdcRapport(self):
#-----------------------#
strRapport = unicode( self.jdc.report() )
+ # on ajoute les regles
+
self._viewText(strRapport, "JDC_RAPPORT")
+ #-----------------------#
+ def viewJdcRegles(self):
+ #-----------------------#
+ if self.tree :self.tree.AppelleBuildLBRegles()
+
+
#----------------#
def closeIt(self):
#----------------#
# appele par I_MACRO_ETAPE
QMessageBox.information( self, titre, message)
+ #-----------------------------------#
+ def affiche_commentaire(self,message):
+ #-----------------------------------#
+ self.labelCommentaire.setText(message)
+
#-------------------#
def init_modif(self):
#-------------------#
def handleDeplier(self):
#---------------------#
if self.tree == None : return
- self.tree.collapseAll()
+ #self.tree.collapseAll()
if self.deplier :
- self.tree.collapseItem(self.tree.topLevelItem(0))
+ #print "je plie"
+ self.tree.expandItem(self.tree.topLevelItem(0))
self.deplier = False
+ if self.fenetreCentraleAffichee != None :
+ if hasattr(self.fenetreCentraleAffichee.node,'plieToutEtReaffiche'):
+ self.fenetreCentraleAffichee.node.plieToutEtReaffiche()
else:
+ #print "je deplie"
self.tree.expandItem(self.tree.topLevelItem(0))
self.deplier = True
+ if self.fenetreCentraleAffichee != None :
+ if hasattr(self.fenetreCentraleAffichee.node,'deplieToutEtReaffiche'):
+ self.fenetreCentraleAffichee.node.deplieToutEtReaffiche()
#---------------------#
def handleEditCut(self):
self.appliEficas.trUtf8('Wrapper Files (*.xml);;''All Files (*)'))
return fichier
- #----------------------------------#
- def writeFile(self, fn, txt = None):
- #----------------------------------#
+ #--------------------------------------------------#
+ def writeFile(self, fn, txt = None,formatLigne="beautifie"):
+ #--------------------------------------------------#
"""
Public slot to write the text to a file.
"""
fn = unicode(fn)
-
+
if txt == None :
- txt = self.get_text_JDC(self.format)
+ txt = self.get_text_JDC(self.format,formatLigne=formatLigne)
eol = '\n'
if len(txt) >= len(eol):
if txt[-len(eol):] != eol:
.arg(unicode(fn)).arg(str(why)))
return 0
- #-------------------------------------#
- def get_text_JDC(self,format,pourRun=0):
- #-------------------------------------#
+ #-----------------------------------------------------------#
+ def get_text_JDC(self,format,pourRun=0,formatLigne="beautifie"):
+ #-----------------------------------------------------------#
if self.code == "MAP" and not(generator.plugins.has_key(format)): format = "MAP"
if generator.plugins.has_key(format):
+
# Le generateur existe on l'utilise
self.generator=generator.plugins[format]()
try :
- jdc_formate=self.generator.gener(self.jdc,format='beautifie',config=self.appliEficas.CONFIGURATION)
+ jdc_formate=self.generator.gener(self.jdc,format=formatLigne,config=self.appliEficas.CONFIGURATION)
if pourRun : jdc_formate=self.generator.textePourRun
except ValueError,e:
QMessageBox.critical(self, tr("Erreur a la generation"),str(e))
#textePython="ls -l"
self._viewTextExecute( textePython,"map_run",".sh")
- try:
- commande="rm "+self.fichierMapInput
- os.system(commande)
- except :
- pass
+ #try:
+ # commande="rm "+self.fichierMapInput
+ # os.system(commande)
+ #except :
+ # pass
except Exception, e:
print traceback.print_exc()
)
return
if hasattr(self.CONFIGURATION, "savedir"): path=self.CONFIGURATION.savedir
- else : path=os.environ['HOME']
+ else : path='C:/'
monNomFichier=""
if self.fichier is not None and self.fichier != "" :
(output, err) = p.communicate()
+ #-----------------#
+ def saveRunPSEN(self):
+ #-----------------#
+ print "saveRunPSEN"
+ self.saveFile()
+ return
+ if not(self.jdc.isvalid()):
+ QMessageBox.critical( self, tr( "Sauvegarde de l'input impossible "),
+ tr("Un JdC valide est necessaire pour creer un .input")
+ )
+ return
+
+ print generator.plugins.has_key(self.format)
+ if generator.plugins.has_key(self.format):
+ # Le generateur existe on l'utilise
+ self.generator=generator.plugins[self.format]()
+ try :
+ self.generator.gener(self.jdc)
+ self.generator.writeDefault('')
+ except ValueError,e:
+ QMessageBox.critical(self, tr("Erreur a la generation"),str(e))
+ if not self.generator.cr.estvide():
+ self.affiche_infos(tr("Erreur a la generation"),Qt.red)
+ QMessageBox.critical( self, tr("Erreur a la generation"),tr("EFICAS ne sait pas convertir ce JDC"))
+ return ""
+ else:
+ # Il n'existe pas c'est une erreur
+ self.affiche_infos(tr("Format %s non reconnu" , self.format),Qt.red)
+ QMessageBox.critical( self, "Format non reconnu" ,tr("EFICAS ne sait pas convertir le JDC selon le format "+ self.format))
+ return ""
+ print "HELLO"
+
+
+
+
#-----------------------------------------#
def cherche_Groupes(self):
#-----------------------------------------#
#else :
pass
- #-----------------------------------------#
- def saveFile(self, path = None, saveas= 0):
- #-----------------------------------------#
+ #-----------------------------------------------------------------#
+ def saveFile(self, path = None, saveas= 0,formatLigne="beautifie"):
+ #-----------------------------------------------------------------#
"""
Public slot to save the text to a file.
the name of the saved file
"""
- #self.modified=1
+ self.modified=1
if not self.modified and not saveas:
return (0, None) # do nothing if text wasn't changed
fn = unicode(QDir.convertSeparators(fn))
newName = fn
- if not (self.writeFile(fn)): return (0, None)
+
+ if not (self.writeFile(fn,formatLigne=formatLigne)): return (0, None)
self.fichier = fn
self.modified = False
if self.fileInfo is None or saveas:
return (1, self.fichier)
#
+
+ #----------------------------------------------#
+ def sauveLigneFile(self):
+ #----------------------------------------------#
+ self.modified=1
+ return self.saveFile(formatLigne="Ligne")
+
+
#----------------------------------------------#
def saveFileAs(self, path = None,fileName=None):
#----------------------------------------------#
if fileName != None :
self.fichier = fileName
return self.saveFile()
- return self.saveFile(path,1)
+ return self.saveFile(path,1,"beautifie")
return ligne
+ #---------------------------#
+ def _newTELEMAC(self):
+ #---------------------------#
+ texte="INITIALIZATION();BOUNDARY_CONDITIONS();GENERAL_PARAMETERS();PHYSICAL_PARAMETERS();NUMERICAL_PARAMETERS();"
+ #texte=""
+ return texte
+
+ #---------------------------#
+ def _newPSEN(self):
+ #---------------------------#
+ texte="DIRECTORY() ; PSSE_PARAMETERS() ; SIMULATION() ; sansnom=DISTRIBUTION() ; sansnom=DISTRIBUTION() ; CORRELATION() ;"
+ #texte=""
+ return texte
+
+ #---------------------------#
+
#---------------------------#
def _newZCRACKS(self):
#---------------------------#