From: Charles Toulemonde Date: Wed, 25 Jan 2012 06:29:27 +0000 (+0000) Subject: ajout de la méthode writeDefault et préparation du fichier .input pour le run X-Git-Tag: LOGILAB~236 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6ca18ca81fa76f0fb4385e490abc9bc8db039711;p=tools%2Feficas.git ajout de la méthode writeDefault et préparation du fichier .input pour le run --- diff --git a/generator/generator_map.py b/generator/generator_map.py index 4766a880..03c59ce4 100644 --- a/generator/generator_map.py +++ b/generator/generator_map.py @@ -60,10 +60,14 @@ class MapGenerator(PythonGenerator): # Les extensions de fichier permis? extensions=('.map',) + def writeDefault(self, fn): + print "data saved in file ", fn def initialise(self,config): self.config=config - self.nom_racine=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/" +# self.nom_racine=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/" +# print "*"*50+"\n"+self.nom_racine + self.nom_racine = "/tmp" if not( os.path.exists(self.nom_racine)): os.makedirs(self.nom_racine) self.listeCODE=[] @@ -73,9 +77,9 @@ class MapGenerator(PythonGenerator): self.INSTALLDIR=self.config.appli.INSTALLDIR self.ssCodeDir=os.path.join(self.INSTALLDIR,'MAP/Templates',self.ssCode) self.fichierYacs=self.ssCode+"_YACS_nodes" - self.texteExecution="import os,sys\n" - self.texteExecution+="sys.path.append('"+self.ssCodeDir+"')\n" - self.texteExecution+="from " + self.fichierYacs +" import *\n" +# self.texteExecution="import os,sys\n" +# self.texteExecution+="sys.path.append('"+self.ssCodeDir+"')\n" +# self.texteExecution+="from " + self.fichierYacs +" import *\n" def gener(self,obj,format='brut',config=None): self.initialise(config) @@ -85,12 +89,25 @@ class MapGenerator(PythonGenerator): def generRUN(self,obj,format='brut',config=None,): self.initialise(config) text=PythonGenerator.gener(self,obj,format) + string = "" for elt in self.listeCODE: code=elt.keys()[0] + string = "[" + code + "]\n" self.dico=elt[code] + for key in self.dico.keys(): + string += key + "=" + str(self.dico[key]) + "\n" if code in self.__class__.__dict__.keys(): texteCode=apply(self.__class__.__dict__[code],(self,)) self.texteExecution += texteCode + self.temp_parameter_file = os.tempnam(None, "map_" + code + "_") + self.texteExecution = os.path.join(os.getenv("MAP_DIRECTORY"), "runMAP") + self.texteExecution += " " + self.temp_parameter_file + f_id = open(self.temp_parameter_file, "w") + f_id.write(string) + f_id.close() + print "parameter file name :", self.temp_parameter_file + print string + print "command :", self.texteExecution return self.texteExecution