--- /dev/null
+# -*- coding: utf-8 -*-\r
+# CONFIGURATION MANAGEMENT OF EDF VERSION\r
+# ======================================================================\r
+# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG\r
+# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY\r
+# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY\r
+# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR\r
+# (AT YOUR OPTION) ANY LATER VERSION.\r
+#\r
+# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT\r
+# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF\r
+# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU\r
+# GENERAL PUBLIC LICENSE FOR MORE DETAILS.\r
+#\r
+# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE\r
+# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,\r
+# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.\r
+#\r
+#\r
+# ======================================================================\r
+"""\r
+ Ce module sert pour charger les paramètres de configuration d'EFICAS\r
+"""\r
+# Modules Python\r
+import os, sys, string, types, re\r
+import traceback\r
+from PyQt4.QtGui import *\r
+from utils import read_file\r
+\r
+# Modules Eficas\r
+from Editeur import utils\r
+\r
+class CONFIG_BASE:\r
+\r
+ #--------------------------------------\r
+ def __init__(self,appli,repIni,nomDir):\r
+ #--------------------------------------\r
+\r
+ # Classe de base permettant de lire, afficher\r
+ # et sauvegarder les fichiers utilisateurs \r
+ # On a deux directories : la directory generale (Repertoire d instal + Nom du code\r
+ # Par exemple : ~/Install_Eficas/EficasV1_14/Openturns_Wrapper\r
+ # et la directorie de l utilisateur \r
+ # HOME/.Eficas_Openturns\r
+ # Le fichier prefs.py va etre lu dans la directory generale puis surcharge eventuellement \r
+ # par celui de l utilisateur\r
+ # le fichier de catalogue va etre lu dans la directory de l utilisateur s il exite\r
+ # dans le fichier general sinon\r
+ self.appli = appli \r
+ self.code = appli.code\r
+ self.salome = appli.salome\r
+ self.repIni = repIni\r
+ self.REPINI = repIni\r
+ self.rep_user = os.path.join(os.environ['HOME'],nomDir)\r
+ \r
+ if self.appli: \r
+ self.parent=appli.top\r
+ self.appli.mode_nouv_commande='initial'\r
+ else: self.parent=None\r
+\r
+\r
+\r
+ def setValeurs(self):\r
+ #---------------------\r
+ \r
+ # Valeurs par defaut\r
+ if not os.path.isdir(self.rep_user) : os.mkdir(self.rep_user)\r
+ self.initialdir = self.rep_user\r
+ self.path_doc = self.rep_user\r
+ self.savedir = self.rep_user\r
+ self.exec_acrobat = self.rep_user\r
+ \r
+ #Lecture des fichiers utilisateurs\r
+ self.lecture_fichier_ini_standard()\r
+ self.lecture_fichier_ini_utilisateur()\r
+ self.lecture_catalogues()\r
+\r
+ #--------------------------------------\r
+ def lecture_fichier_ini_standard(self):\r
+ #--------------------------------------\r
+ # Verifie l'existence du fichier "standard"\r
+ # appelle la lecture de ce fichier\r
+ import prefs\r
+ name='prefs_'+prefs.code\r
+ prefsCode=__import__(name)\r
+ self.prefsUser=name+".py"\r
+ for k in self.labels_eficas :\r
+ try :\r
+ valeur=getattr(prefsCode,k)\r
+ setattr(self,k,valeur)\r
+ except :\r
+ pass\r
+ if hasattr(self,'map_path') :\r
+ oldPath=self.map_path\r
+ \r
+\r
+ #--------------------------------------\r
+ def lecture_fichier_ini_utilisateur(self):\r
+ #--------------------------------------\r
+ # Surcharge les paramètres standards par les paramètres utilisateur s'ils existent\r
+ self.fic_ini_utilisateur = os.path.join(self.rep_user,self.prefsUser)\r
+ if not os.path.isfile(self.fic_ini_utilisateur): return\r
+\r
+ txt = utils.read_file(self.fic_ini_utilisateur)\r
+ from styles import style\r
+ d=locals()\r
+ try:\r
+ exec txt in d\r
+ except :\r
+ l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2])\r
+ QMessageBox.critical( None, "Import du fichier de Configuration", \r
+ "Erreur à la lecture du fichier de configuration " + self.fic_ini_utilisateur )\r
+ sys.exit(0)\r
+ for k in self.labels_user :\r
+ try :\r
+ setattr(self,k,d[k])\r
+ except :\r
+ pass\r
+\r
+\r
+ #--------------------------------------\r
+ def lecture_catalogues(self):\r
+ #--------------------------------------\r
+ rep_mat=" " # Compatibilite Aster\r
+ if hasattr(self,"catalogues") : return\r
+ \r
+ fic_ini = os.path.join(self.repIni,self.cataFile)\r
+ if not os.path.isfile(fic_ini) :\r
+ QMessageBox.critical( None, "Erreur a l'import du fichier des Catalogues", \r
+ "Le fichier de configuration des catalogues "+fic_ini+" n a pas été trouvé" )\r
+ sys.exit(0)\r
+\r
+ txt = utils.read_file(fic_ini)\r
+ d=locals()\r
+ try:\r
+ exec txt in d\r
+ self.catalogues=d["catalogues"]\r
+ except :\r
+ l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2])\r
+ QMessageBox.critical( None, "Import du fichier de Configuration", \r
+ "Erreur à la lecture du fichier de configuration " + fic_ini )\r
+ sys.exit(0)\r
+\r
+\r
+\r
+ #--------------------------------------\r
+ def save_params(self):\r
+ #--------------------------------------\r
+ # sauvegarde\r
+ # les nouveaux paramètres dans le fichier de configuration utilisateur\r
+ #\r
+ texte=""\r
+ for clef in self.labels_user :\r
+ if hasattr(self,clef):\r
+ valeur=getattr(self,clef)\r
+ texte= texte + clef+" = " + repr(valeur) +"\n"\r
+ f=open(self.fic_ini_utilisateur,'w+')\r
+ print self.fic_ini_utilisateur\r
+ f.write(texte) \r
+ f.close()\r
+#\r
+\r
else:
return self.textePython
- #-----------------------------#
- def runYACS(self,execution="oui"):
- #-----------------------------#
+ #------------------------------------------------#
+ def runYACS(self,execution="oui",nomFichier=None):
+ #------------------------------------------------#
format=self.appliEficas.format_fichier
- self.textePython=""
if generator.plugins.has_key(format):
# Le generateur existe on l'utilise
self.generator=generator.plugins[format]()
- self.textePython =self.generator.generRUNYACS(self.jdc,format='beautifie',config=self.appliEficas.CONFIGURATION)
+ self.generator.generRUNYACS(self.jdc,format='beautifie',config=self.appliEficas.CONFIGURATION,nomFichier=nomFichier)
if execution=="oui" :
print "il faut faire le run dans Salome"
- else:
- return self.textePython
#-----------------------------#
def saveRun(self):
#-----------------------------#
def saveYACS(self):
#-----------------------------#
- texte=self.runYACS(execution="non")
path=self.CONFIGURATION.savedir
fn = QFileDialog.getSaveFileName( self,
self.trUtf8("sauvegarde"), path,
- self.trUtf8("JDC (*.py);;" "All Files (*)"),None,
+ self.trUtf8("JDC (*.xml);;" "All Files (*)"),None,
QFileDialog.DontConfirmOverwrite)
if fn.isNull(): return
ext = QFileInfo(fn).suffix()
self.trUtf8("&Ecraser"),
self.trUtf8("&Abandonner"))
if abort == 1 : return
-
fn = unicode(QDir.convertSeparators(fn))
- self.writeFile( fn, txt = texte)
+
+ texte=self.runYACS(execution="non",nomFichier=fn)
+ #self.writeFile( fn, txt = texte)
- #-----------------------------------------#e
+ #-----------------------------------------#
def cherche_Groupes(self):
+ #-----------------------------------------#
listeMA,listeNO=self.get_text_JDC("GroupMA")
return listeMA,listeNO
- #-----------------------------------------#
#-----------------------------------------#
def saveFile(self, path = None, saveas= 0):
self.tree.racine.item.getObject().nom=os.path.basename(newName)
self.tree.racine.update_node_label()
- try :
- fileXML = fn[:fn.rfind(".")] + '.xml'
- self.generator.writeOpenturnsXML( fileXML )
- except :
- pass
+ if self.jdc.isvalid() != 0 :
+ try :
+ fileXML = fn[:fn.rfind(".")] + '.xml'
+ self.generator.writeOpenturnsXML( fileXML )
+ except :
+ pass
- try :
- fileSTD = fn[:fn.rfind(".")] + '.py'
- self.generator.writeOpenturnsSTD( fileSTD )
- except :
- pass
-
- try:
- self.generator.writeDefault(fn)
- except:
- pass
-
- try :
- fileCuve2DG = fn[:fn.rfind(".")] + '.don'
- self.generator.writeCuve2DG(fileCuve2DG)
- except :
- pass
-
- #try :
- # self.tubePy=self.generator.getTubePy()
- # fileTube = fn[:fn.rfind(".")] + '.py'
- # if self.tubePy != '' :
- # f=open(fileTube,'w')
- # f.write(self.tubePy)
- # f.close()
- #except :
- # pass
+ try :
+ fileSTD = fn[:fn.rfind(".")] + '.py'
+ self.generator.writeOpenturnsSTD( fileSTD )
+ except :
+ pass
+
+ try:
+ self.generator.writeDefault(fn)
+ except:
+ pass
+
+ try :
+ fileCuve2DG = fn[:fn.rfind(".")] + '.don'
+ self.generator.writeCuve2DG(fileCuve2DG)
+ except :
+ pass
+
if self.salome :
self.appliEficas.addJdcInSalome( self.fichier)
à l'utilisateur de choisir une seule valeur parmi une liste de valeurs
discrètes
"""
- def __init__(self, choixCata,name = None,fl = 0):
- QtGui.QDialog.__init__(self)
+ def __init__(self, choixCata,parentQT=None,parentAppli=None):
+ QtGui.QDialog.__init__(self,parentQT)
self.setMinimumSize(50, 50);
self.setModal(True)
self.setupUi(self)
self.ajouteCeQuilFaut()
self.choixCata=choixCata
+ self.parentAppli=parentAppli
def ajouteCeQuilFaut(self) :
schema=str(self.groupScheme.checkedButton().text())
self.choixCata.schema=schema
nomCata= dico[self.module][schema]
- self.choixCata.nom=nomCata
+ if self.parentAppli==None :
+ self.choixCata.nom=nomCata
+ else :
+ self.parentAppli.ssCode=nomCata
self.close();
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os, re, sys
+
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+
+from OptionsMAP import Ui_desOptions
+
+
+class desOptions(Ui_desOptions,QDialog):
+ def __init__(self,parent ,modal ) :
+ QDialog.__init__(self,parent)
+ self.setupUi(self)
+ self.setModal(modal)
+
+class Options(desOptions):
+ def __init__(self,parent = None,modal = 0,configuration=None):
+ desOptions.__init__(self,parent,modal)
+ self.configuration=configuration
+ self.viewMan=parent
+ self.dVersion={}
+ self.dRepCat={}
+ self.connecterSignaux()
+ self.initAll()
+
+ def connecterSignaux(self) :
+ self.connect(self.CBVersions,SIGNAL("activated(int)"),self.VersionChoisie)
+ self.connect(self.Bdefaut,SIGNAL("clicked()"),self.BdefautChecked)
+ self.connect(self.LEVersionAjout,SIGNAL("returnPressed()"),self.AjoutVersion)
+ self.connect(self.PBajout,SIGNAL("clicked()"),self.AjoutVersion)
+ self.connect(self.LEVersionSup,SIGNAL("returnPressed()"),self.SupVersion)
+ self.connect(self.PBSup,SIGNAL("clicked()"),self.SupVersion)
+ self.connect(self.LERepDoc,SIGNAL("returnPressed()"),self.ChangePathDoc)
+ self.connect(self.LERepOT,SIGNAL("returnPressed()"),self.ChangePathOT)
+ self.connect(self.LERepMAP,SIGNAL("returnPressed()"),self.ChangePathMAP)
+ self.connect(self.LERepAster,SIGNAL("returnPressed()"),self.ChangePathAster)
+ self.connect(self.LERepCata,SIGNAL("returnPressed()"),self.BokClicked)
+ self.connect(self.LESaveDir,SIGNAL("returnPressed()"),self.ChangeSaveDir)
+ self.connect(self.Bok,SIGNAL("clicked()"),self.BokClicked)
+ self.connect(self.PBQuit,SIGNAL("clicked()"),self.close)
+
+
+ def initAll(self):
+ self.CBVersions.clear()
+ for item in self.configuration.catalogues :
+ (code,ssCode,cata,formatOut,formatIn)=item
+ self.dVersion[ssCode]=(item)
+ self.dRepCat[ssCode]=str(cata)
+ self.CBVersions.addItem(QString(ssCode))
+ self.LERepCata.setText(self.dRepCat[str(self.CBVersions.currentText())])
+
+ if hasattr(self.configuration,"path_doc"):
+ self.LERepDoc.setText(self.configuration.path_doc)
+ if hasattr(self.configuration,"OpenTURNS_path"):
+ self.LERepOT.setText(self.configuration.OpenTURNS_path)
+ if hasattr(self.configuration,"savedir"):
+ self.LESaveDir.setText(self.configuration.savedir)
+ if hasattr(self.configuration,"PATH_MAP"):
+ self.LERepMAP.setText(self.configuration.PATH_MAP)
+ if hasattr(self.configuration,"PATH_ASTER"):
+ self.LERepAster.setText(self.configuration.PATH_ASTER)
+
+ def ChangePathMAP(self):
+ if self.LERepMAP.text()=="" : return
+ if not os.path.isdir(self.LERepMAP.text()) :
+ res = QMessageBox.warning( None,
+ self.trUtf8("Repertoire MAP "),
+ self.trUtf8("Le Repertoire n existe pas."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ if res == 1 :
+ if hasattr(self.configuration,"PATH_MAP"):
+ self.LERepAster.setText(self.configuration.PATH_MAP)
+ return
+ self.configuration.PATH_MAP=str(self.LERepMAP.text())
+ self.configuration.PATH_PYGMEE=self.configuration.PATH_MAP+"/components/pygmee_v1"
+ self.configuration.PATH_BENHUR=self.configuration.PATH_MAP+"/components/benhur"
+ self.configuration.PATH_FDVGRID=self.configuration.PATH_MAP+"components/fdvgrid/ther2d/bin"
+ self.configuration.PATH_MODULE=self.configuration.PATH_MODULE+"components/fdvgrid/ther2d/bin"
+ self.configuration.save_params()
+
+ def VersionChoisie(self):
+ version=str(self.CBVersions.currentText())
+ pass
+
+ def ChangePathAster(self):
+ if self.LERepAster.text()=="" : return
+ if not os.path.isdir(self.LERepAster.text()) :
+ res = QMessageBox.warning( None,
+ self.trUtf8("Repertoire Aster "),
+ self.trUtf8("Le Repertoire n existe pas."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ if res == 1 :
+ if hasattr(self.configuration,"PATH_ASTER"):
+ self.LERepAster.setText(self.configuration.PATH_ASTER)
+ return
+ self.configuration.PATH_ASTER=str(self.LERepAster.text())
+ self.configuration.save_params()
+
+ def VersionChoisie(self):
+ version=str(self.CBVersions.currentText())
+ if self.dRepCat.has_key(version):
+ self.LERepCata.setText(self.dRepCat[version])
+
+ def BokClicked(self):
+ version=str(self.CBVersions.currentText())
+ if self.LERepCata.text() == "" :
+ QMessageBox.critical( self, "Champ non rempli","Le champ Catalogue doit etre rempli" )
+ return
+ if not os.path.isfile(self.LERepCata.text()) :
+ res = QMessageBox.warning( None,
+ self.trUtf8("Fichier Catalogue "),
+ self.trUtf8("Le Fichier n existe pas. Voulez-vous supprimer cette version ?"),
+ self.trUtf8("&Oui"),
+ self.trUtf8("&Non"))
+ if res == 0 :
+ self.LEVersionSup.setText(version)
+ self.SupVersion()
+ return
+
+ self.dRepCat[version]=str(self.LERepCata.text())
+ if version in self.dVersion.keys():
+ item=list(self.dVersion[version])
+ item[2]=self.dRepCat[version]
+ self.dVersion[version]=tuple(item)
+ else :
+ import prefs
+ code=prefs.code
+ self.dVersion[version]=(code,version,self.dRepCat[version],code.lower())
+
+ lItem=[]
+ for version in self.dVersion.keys() :
+ lItem.append(self.dVersion[version])
+ self.configuration.catalogues=lItem
+ self.configuration.save_params()
+
+ def AjoutVersion(self):
+ version=self.LEVersionAjout.text()
+ if str(version) == "" : return
+ self.CBVersions.addItem(version)
+ self.LERepCata.setText("")
+ self.LEVersionAjout.setText("")
+ self.CBVersions.setCurrentIndex(self.CBVersions.count()-1)
+
+ def SupVersion(self):
+ version=str(self.LEVersionSup.text())
+ if version == "" : return
+ i =0
+ while i < self.CBVersions.count() :
+ if self.CBVersions.itemText(i) == version :
+ self.CBVersions.removeItem(i)
+ break
+ i=i+1
+ try :
+ del self.dVersion[version]
+ del self.dRepCat[version]
+ except :
+ self.LEVersionSup.setText("")
+ try :
+ self.CBVersions.setCurrentIndex(self.CBVersions.count()-1)
+ self.VersionChoisie()
+ except :
+ pass
+ return
+ codeSansPoint=re.sub("\.","",version)
+ chaine="rep_mat_"+codeSansPoint
+ if hasattr(self.configuration,chaine):
+ delattr(self.configuration,chaine)
+ self.LEVersionSup.setText("")
+
+ lItem=[]
+ for version in self.dVersion.keys() :
+ lItem.append(self.dVersion[version])
+ self.LERepCata.setText("")
+ self.configuration.catalogues=lItem
+ self.configuration.save_params()
+ self.CBVersions.setCurrentIndex(0)
+ self.VersionChoisie()
+
+
+ def BdefautChecked(self):
+ res = QMessageBox.warning( None,
+ self.trUtf8("Restauration des parametres par defaut "),
+ self.trUtf8("Votre fichier editeur sera ecrase."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ self.Bdefaut.setCheckState(Qt.Unchecked)
+ if res == 1 : return
+
+ appli=self.configuration.appli
+ fic_ini_util=self.configuration.fic_ini_utilisateur
+ old_fic_ini_util=fic_ini_util+"_old"
+ commande="mv "+fic_ini_util+" "+old_fic_ini_util
+ os.system(commande)
+ import prefs
+ name='prefs_'+prefs.code
+ prefsCode=__import__(name)
+ repIni=prefsCode.REPINI
+ nameConf='configuration_'+prefs.code
+ configuration=__import__(nameConf)
+
+ configNew=configuration.CONFIG(appli,repIni)
+ self.configuration=configNew
+ appli.CONFIGURATION=configNew
+ self.configuration.save_params()
+ self.dVersion={}
+ self.dRepCat={}
+ self.initAll()
+
+ def ChangePathDoc(self):
+ if self.LERepDoc.text()=="" : return
+ if not os.path.isdir(self.LERepDoc.text()) :
+ res = QMessageBox.warning( None,
+ self.trUtf8("Repertoire de Documentation "),
+ self.trUtf8("Le Repertoire n existe pas."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ if res == 1 :
+ if hasattr(self.configuration,"path_doc"):
+ self.LERepDoc.setText(self.configuration.path_doc)
+ return
+
+ self.configuration.path_doc=str(self.LERepDoc.text())
+ self.configuration.save_params()
+
+ def ChangePathOT(self):
+ if not os.path.isdir(self.LERepOT.text()) :
+ res = QMessageBox.warning( None,
+ self.trUtf8("Repertoire Open TURNS "),
+ self.trUtf8("Le Repertoire n existe pas."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ if res == 1 :
+ if hasattr(self.configuration,"OpenTURNS_path"):
+ self.LERepOT.setText(self.configuration.OpenTURNS_path)
+ return
+
+ if hasattr(self.configuration,"OpenTURNS_path"):
+ sys.path.remove(self.configuration.OpenTURNS_path)
+ self.configuration.OpenTURNS_path=str(self.LERepOT.text())
+ self.configuration.save_params()
+ if self.configuration.OpenTURNS_path == "" : return
+ sys.path[:0]=[self.configuration.OpenTURNS_path]
+
+ def ChangeSaveDir(self):
+ if not os.path.isdir(self.LESaveDir.text()) :
+ res = QMessageBox.warning( None,
+ self.trUtf8("Repertoire Open TURNS "),
+ self.trUtf8("Le Repertoire n existe pas."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ if res == 1 :
+ if hasattr(self.configuration,"savedir"):
+ self.LESaveDir.setText(self.configuration.savedir)
+ self.configuration.savedir=str(self.LESaveDir.text())
+ self.configuration.save_params()
+
self.dict_reels={}
import prefs
- #print prefs
prefs.code=code
name='prefs_'+prefs.code
prefsCode=__import__(name)
def saveCurrentEditor(self):
index=self.myQtab.currentIndex()
if index < 0 : return
+ print self
+ print index
+ print self.dict_editors
editor=self.dict_editors[index]
if editor in self.doubles.keys() :
QMessageBox.warning(
\r
self.labels_user=['exec_acrobat', 'catalogues','savedir','path_doc','map_path']\r
self.labels_user=self.labels_user+['PATH_PYGMEE','PATH_BENHUR','PATH_ASTER','PATH_MODULE']\r
- self.labels_user=self.labels_user+['PATH_STUDY','NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path']\r
+ self.labels_user=self.labels_user+['PATH_STUDY','NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path','PATH_GMSH']\r
\r
self.labels_eficas=["map_path","rep_user","INSTALLDIR","path_doc","exec_acrobat"]\r
self.labels_eficas=self.labels_eficas+["rep_cata","initialdir","savedir","catalogues",'PATH_PYGMEE']\r
self.labels_eficas=self.labels_eficas+['PATH_BENHUR','PATH_ASTER','PATH_MODULE','PATH_STUDY']\r
- self.labels_eficas=self.labels_eficas+['NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path']\r
+ self.labels_eficas=self.labels_eficas+['NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path','PATH_GMSH']\r
\r
self.cataFile="catalogues_MAP.ini"\r
self.setValeurs()\r
PATH_MODULE=PATH_MAP+"/modules/polymers"\r
PATH_STUDY=PATH_MAP+"/studies/demonstrateur_poly_st1"\r
PATH_ASTER="/local/noyret/bin/Aster10/bin"\r
+PATH_GMSH="/usr/bin"\r
\r
\r
# Codage des strings qui accepte les accents (en remplacement de 'ascii')\r
#MonChoixCata.nom=cata
#permet de choisir le module
-print MonChoixCata.nom
eficas_go.lance_eficas(code=prefs.code,ssCode=MonChoixCata.nom)
#eficas_go.lance_eficas(code=prefs.code,choix="non")
#CONTEXT.debug = 1
JdC = JDC_CATA ( code = 'MAP',
execmodul = None,
- regles=(AU_MOINS_UN('PYGMEE',),AU_MOINS_UN('BENHUR',), AVANT ('PYGMEE' , 'BENHUR'),),
- )# Fin JDC_CATA
+ regles=(AU_MOINS_UN('PYGMEE',),
+ AU_MOINS_UN('BENHUR',),
+ AVANT ('PYGMEE' , 'BENHUR'),
+ AVANT('ASTER','GMSH'),
+ EXCLUS('ASTER','FDVGRID'),
+ ),
+ )# Fin JDC_CATA
#
PYGMEE= PROC(nom="PYGMEE",op=None,
--- /dev/null
+# -*- coding: utf-8 -*-
+
+# --------------------------------------------------
+# debut entete
+# --------------------------------------------------
+
+import Accas
+from Accas import *
+
+class loi ( ASSD ) : pass
+class variable ( ASSD ) : pass
+
+
+#CONTEXT.debug = 1
+JdC = JDC_CATA ( code = 'OPENTURNS_STUDY',
+ execmodul = None,
+ regles = ( AU_MOINS_UN ( 'CRITERIA' ), ),
+ ) # Fin JDC_CATA
+
+# --------------------------------------------------
+# fin entete
+# --------------------------------------------------
+#===============================
+# 5. Definition des parametres
+#===============================
+VARI = OPER ( nom = "VARI",
+ sd_prod = variable,
+ op = None,
+ fr = "Definitions des lois marginales utilisees par les variables d'entree",
+ type=SIMP(statut='f',defaut="IN",into=("IN","OUT"), typ = "TXM",)
+ )
+
+VARI1 = OPER ( nom = "VARI1",
+ sd_prod = variable,
+ op = None,
+ fr = "Definitions des lois marginales utilisees par les variables d'entree",
+
+ POUTRE = FACT(statut= 'f',max= '**',
+ MAILLE = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'),
+ GROUP_MA = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'),
+ ),
+ POUTRE2 = FACT(statut= 'f',max= '**',
+ MAILLE2 = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'),
+ GROUP_MA2 = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'),
+ ),
+ FINAL =FACT(statut= 'f',max= '**',
+ type=SIMP(statut='f',min=1,max= '**', into=("POUTRE","POUTRE2"),
+ validators=[VerifExiste(2),NoRepeat()], typ="TXM",),
+ ),
+ )
+
+
+FICXML=MACRO(nom="FICXML",
+ op=None,
+ UIinfo={"groupes":("Gestion du travail",)},
+ fr="Débranchement vers un fichier de commandes secondaires",
+ sd_prod=loi,
+ FICHIER = SIMP(statut='o',typ='TXM',),
+);
+
return self.texteExecution
- def generRUNYACS(self,obj,format='brut',config=None):
+ def generRUNYACS(self,obj,format='brut',config=None,nomFichier=None):
self.initialise(config)
text=PythonGenerator.gener(self,obj,format)
import sys
if hasattr(self.monSchema, codeYACS):
fct=getattr(self.monSchema, codeYACS)
fct(self.proc,dico)
- self.monSchema.write_yacs_proc(self.proc,"/tmp/toto.xml")
- return "/tmp/toto.xml"
+ self.monSchema.write_yacs_proc(self.proc,str(nomFichier))
def generePythonMap(self,execution) :
'''
#____________________________________________________________________________________
# Liste des mots cles de config remplaces dans les fichiers à trous
#
-CONFIGliste=('NAME_SCHEME', 'PATH_ASTER', 'PATH_BENHUR', 'PATH_MODULE', 'PATH_PYGMEE', 'PATH_STUDY', 'repIni', 'PATH_FDVGRID')
+CONFIGliste=('NAME_SCHEME', 'PATH_ASTER', 'PATH_BENHUR', 'PATH_MODULE', 'PATH_PYGMEE', 'PATH_STUDY', 'repIni', 'PATH_FDVGRID' ,'PATH_GMSH')
#_____________________________________________________________________
# Attention les variables suivantes sont nécessaires entre les codes :
monFichierCommOutput=self.nom_racine+"s_poly_st_1_aster.comm"
monFichierExportOutput=self.nom_racine+"s_poly_st_1_aster.export"
+ self.monFichierMSH=self.nom_racine+"/"+self.config.NAME_SCHEME+"_aster.resu.msh"
monFichierCommInput=self.config.INSTALLDIR+"/MAP/Templates/"+self.ssRepertoire+"/s_poly_st_1_aster_template.comm"
monFichierExportInput=self.config.INSTALLDIR+"/MAP/Templates/"+self.ssRepertoire+"/s_poly_st_1_aster_template.export"
if ('_ASTER_LANCEMENT' in dicoAster.keys()) and dicoAster['_ASTER_LANCEMENT'] == 'oui':
commande="cd "+self.config.PATH_MODULE+";"
- commande=commande + self.config.PATH_ASTER + "/as_run "+monFichierExportOutput
+ commande=commande + self.config.PATH_ASTER + "bin/as_run "+monFichierExportOutput +";\n"
return commande
else:
return ""
def GMSH(self,execution) :
dicoGmsh=self.dictMCVal["GMSH"]
if ('_GMSH_LANCEMENT' in dicoGmsh.keys()) and dicoGmsh['_GMSH_LANCEMENT'] == 'oui':
- commande="cd "+self.config.PATH_MODULE+";"
- commande=commande + "gmsh "+self.config.PATH_MODULE+"/"+self.config.NAME_SCHEME+"/"+self.config.NAME_SCHEME+"_aster.resu.msh"
- print commande
- os.system(commande)
+ commande=self.config.PATH_GMSH+"/gmsh "
+ commande=commande + self.monFichierMSH+";\n"
+ return commande
else:
return ""
-
--- /dev/null
+#!/usr/bin/env python
+
+import pilot
+import SALOMERuntime
+import loader
+import logging
+import traceback
+import os
+
+class CreeSchemaYacs :
+ def __init__(self,config):
+ print "dans le init de CreeSchemaYacs "
+ self.config=config
+ self.ssCode=config.appli.ssCode
+ self.setUp()
+ self.addCatalog()
+ self.nodeAvant=None
+
+ def setUp(self):
+ SALOMERuntime.RuntimeSALOME_setRuntime()
+ self.runtime = pilot.getRuntime()
+ self.loader = loader.YACSLoader()
+ self.loader.registerProcCataLoader()
+
+ def addCatalog(self):
+ try:
+ monCataFile= os.environ["EFICAS_ROOT_DIR"]
+ monCataFile=monCataFile+"/share/salome/resources/eficas/cata"
+ monCataFile=monCataFile+self.ssCode+".xml"
+ print monCataFile
+ self.monCata = self.runtime.loadCatalog("proc",monCataFile)
+ except:
+ logging.fatal("Exception in loading MAP catalog")
+ traceback.print_exc()
+ sys.exit(1)
+
+ def createProc(self):
+ proc = self.runtime.createProc("proc")
+ proc.setTypeCode("pyobj", self.runtime.getTypeCode("pyobj"))
+ t_pyobj = proc.getTypeCode("pyobj")
+ t_string = proc.getTypeCode("string")
+ return proc
+
+ def write_yacs_proc(self,proc, yacs_schema_filename):
+ proc.saveSchema(yacs_schema_filename)
+
+class s_poly_st_1(CreeSchemaYacs) :
+
+ def BENHURYACS(self,proc,dico):
+ monFichierInput=self.config.PATH_BENHUR+"/BHR_files.txt"
+ factoryNode = self.monCata._nodeMap["benhur"]
+ self.benhurNode = factoryNode.cloneNode("benhur")
+ self.benhurNode.getInputPort("fileInput").edInitPy(monFichierInput)
+ self.benhurNode.getInputPort("pathBenhur").edInitPy(self.config.PATH_BENHUR)
+ proc.edAddChild(self.benhurNode)
+ if self.nodeAvant != None :
+ proc.edAddCFLink(self.nodeAvant,self.benhurNode)
+ self.nodeAvant=self.benhurNode
+
+ def PYGMEEYACS(self,proc,dico):
+ monFichierInput=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/pygmee_input.txt"
+ factoryNode = self.monCata._nodeMap["pygmee"]
+ self.pygmeeNode = factoryNode.cloneNode("pygmee")
+ self.pygmeeNode.getInputPort("pathPygmee").edInitPy(self.config.PATH_PYGMEE)
+ self. pygmeeNode.getInputPort("fileInput").edInitPy(monFichierInput)
+ proc.edAddChild(self.pygmeeNode)
+ if self.nodeAvant != None :
+ proc.edAddCFLink(self.nodeAvant,self.pygmeeNode)
+ self.nodeAvant=self.pygmeeNode
+
+ def ASTERYACS(self,proc,dico):
+ factoryNode = self.monCata._nodeMap["asterRun"]
+ self.asterNode = factoryNode.cloneNode("asterRun")
+ nom_racine=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/"
+ monFichierExport=nom_racine+"s_poly_st_1_aster.export"
+ monFichierMed=nom_racine+"s_poly_st_1_aster.resu.med"
+ self.asterNode.getInputPort("pathAster").edInitPy(self.config.PATH_ASTER+"/bin")
+ self.asterNode.getInputPort("fileExport").edInitPy(monFichierExport)
+ self.asterNode.getInputPort("fileMed").edInitPy(monFichierMed)
+
+ proc.edAddChild(self.asterNode)
+ if self.nodeAvant != None :
+ proc.edAddCFLink(self.nodeAvant,self.asterNode)
+ self.nodeAvant=self.asterNode
+
+dictKlass={'s_poly_st_1':s_poly_st_1}
+def getSchema(config):
+ schema=config.appli.ssCode
+ return dictKlass[schema](config)
+
+
+if __name__ == "__main__":
+ monCreator=getSchema('s_poly_st_1')
+ proc=monCreator.createProc()
+ monCreator.ajoutPygmee(proc)
+ monCreator.ajoutBenhur(proc)
+ monCreator.write_yacs_proc(proc,"/tmp/toto.xml")
+