From 6ca18ca81fa76f0fb4385e490abc9bc8db039711 Mon Sep 17 00:00:00 2001 From: Charles Toulemonde Date: Wed, 25 Jan 2012 06:29:27 +0000 Subject: [PATCH] =?utf8?q?ajout=20de=20la=20m=C3=A9thode=20writeDefault=20?= =?utf8?q?et=20pr=C3=A9paration=20du=20fichier=20.input=20pour=20le=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- generator/generator_map.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) 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 -- 2.39.2