]> SALOME platform Git repositories - tools/yacsgen.git/commitdiff
Salome HOME
Aster changed some paths in version 11.4 BR_imps_2013 V7_3_0a1
authoromircescu <omircescu>
Mon, 28 Oct 2013 09:47:00 +0000 (09:47 +0000)
committeromircescu <omircescu>
Mon, 28 Oct 2013 09:47:00 +0000 (09:47 +0000)
module_generator/astcompo.py
module_generator/aster_tmpl.py

index d146db192f1aa9b57f66b60ac8b783340b55abc7..cb5ceb317cd0e53f09763558a431c6c94fed6dcd 100644 (file)
@@ -99,6 +99,31 @@ class ASTERComponent(Component):
       if not found:
         serv.inport.insert(0, ("jdc", "string"))
 
+  def getAsterPythonPath(self):
+    """Directory of aster python modules
+    """
+    python_version_dir = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
+    aster_python_path = os.path.join(self.aster_dir, "lib", python_version_dir, "site-packages")
+
+    if not os.path.exists(aster_python_path) :
+      aster_python_path = os.path.join(self.aster_dir, "bibpyt")
+      
+    return aster_python_path
+
+  def getConfig(self, gen):
+    """Content of the config.txt file
+    """
+    path_compo=os.path.join(os.path.abspath(gen.module.prefix),'lib',
+                      'python%s.%s' % (sys.version_info[0], sys.version_info[1]),
+                      'site-packages','salome','%s_component.py'%self.name)
+    conf="""ENV_SH         | env     | -     | $ASTER_VERSION_DIR/share/aster/profile.sh
+BINELE         | bin     | -     | $ASTER_VERSION_DIR/share/aster/elements
+SRCPY          | src     | -     | %s
+ARGPYT         | exec    | -     | %s
+""" % (self.getAsterPythonPath(), path_compo)
+    
+    return conf
+
   def makeCompo(self, gen):
     """drive the generation of SALOME module files and code files
        depending on the choosen component kind
@@ -108,7 +133,7 @@ class ASTERComponent(Component):
     gen.aster = self.aster_dir
 
     #get ASTER version
-    f = os.path.join(self.aster_dir, "bibpyt", 'Accas', 'properties.py')
+    f = os.path.join(self.aster_dir, self.getAsterPythonPath(), 'Accas', 'properties.py')
     self.version=(0,0,0)
     if os.path.isfile(f):
       mydict = {}
@@ -173,15 +198,21 @@ class ASTERComponent(Component):
       fdict["E_SUPERV.py"]=esuperv
 
     #use a specific main program (modification of config.txt file)
-    fil = open(os.path.join(self.aster_dir, "config.txt"))
-    config = fil.read()
-    fil.close()
-    config = re.sub(" profile.sh", os.path.join(self.aster_dir, "profile.sh"), config)
-
-    path=os.path.join(os.path.abspath(gen.module.prefix),'lib',
+    config = ""
+    path_config = os.path.join(self.aster_dir, "config.txt")
+    if os.path.exists(path_config) :
+      # old aster version - old mechanism kept for compatibility
+      fil = open(path_config)
+      config = fil.read()
+      fil.close()
+      config = re.sub(" profile.sh", os.path.join(self.aster_dir, "profile.sh"), config)
+      path=os.path.join(os.path.abspath(gen.module.prefix),'lib',
                       'python%s.%s' % (sys.version_info[0], sys.version_info[1]),
                       'site-packages','salome','%s_component.py'%self.name)
-    config = re.sub("Execution\/E_SUPERV.py", path, config)
+      config = re.sub("Execution\/E_SUPERV.py", path, config)
+    else :
+      # getConfig doesn't work with older versions of aster
+      config = self.getConfig(gen)
 
     fdict["%s_config.txt" % self.name] = config
     fdict["%s_component.py" % self.name] = component.substitute(component=self.name)
@@ -206,20 +237,38 @@ class ASTERComponent(Component):
       fdict["E_SUPERV.py"]=esuperv
 
     #use a specific main program
-    fil = open(os.path.join(self.aster_dir, "config.txt"))
-    config = fil.read()
-    fil.close()
-    config = re.sub(" profile.sh", os.path.join(self.aster_dir, "profile.sh"), config)
-    path=os.path.join(os.path.abspath(gen.module.prefix),'lib',
+    config = ""
+    path_config = os.path.join(self.aster_dir, "config.txt")
+    if os.path.exists(path_config) :
+      # old aster version - old mechanism kept for compatibility
+      fil = open(path_config)
+      config = fil.read()
+      fil.close()
+      config = re.sub(" profile.sh", os.path.join(self.aster_dir, "profile.sh"), config)
+      path=os.path.join(os.path.abspath(gen.module.prefix),'lib',
                       'python%s.%s' % (sys.version_info[0], sys.version_info[1]),
                       'site-packages','salome','%s_container.py' % self.name)
-    config = re.sub("Execution\/E_SUPERV.py", path, config)
+      config = re.sub("Execution\/E_SUPERV.py", path, config)
+    else :
+      # getConfig doesn't work with older versions of aster
+      config = self.getConfig(gen)
 
     fdict["%s_container.py" % self.name] = container
     fdict["%s_config.txt" % self.name] = config
 
     return fdict
 
+  def getImportESuperv(self):
+    importesuperv=""
+    if self.version < (10,1,2):
+      importesuperv="from E_SUPERV import SUPERV"
+    else :
+      importesuperv="""sys.path=["%s"]+sys.path
+from Execution.E_SUPERV import SUPERV
+""" % self.getAsterPythonPath()
+    return importesuperv
+
+
   def makeexeaster(self, gen):
     """standalone component: generate SALOME component source"""
     services = []
@@ -273,12 +322,7 @@ class ASTERComponent(Component):
       services.append(service)
       inits.append(init)
 
-    if self.version < (10,1,2):
-      importesuperv="from E_SUPERV import SUPERV"
-    else:
-      importesuperv="""sys.path=["%s"]+sys.path
-from Execution.E_SUPERV import SUPERV
-""" % os.path.join(self.aster_dir, "bibpyt")
+    importesuperv = self.getImportESuperv()
 
     return asterEXECompo.substitute(component=self.name, module=gen.module.name,
                                     servicesdef="\n".join(defs),
@@ -342,12 +386,7 @@ from Execution.E_SUPERV import SUPERV
       services.append(service)
       inits.append(init)
 
-    if self.version < (10,1,2):
-      importesuperv="from E_SUPERV import SUPERV"
-    else:
-      importesuperv="""sys.path=["%s"] +sys.path
-from Execution.E_SUPERV import SUPERV
-""" % os.path.join(self.aster_dir, "bibpyt")
+    importesuperv = self.getImportESuperv()
 
     return asterCEXECompo.substitute(component=self.name, 
                                      module=gen.module.name,
index 63f6c44e20f8be22e09870aca72de3b67176eca8..0dc65a69310270c3c12bb4ffe984d34b2cb9d318 100644 (file)
@@ -62,10 +62,15 @@ class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUP
     if hasattr(self,"init_timer"):
       self.init_timer()
     #fin modif pour aster 9.0
-    if os.path.exists(os.path.join(aster_dir,"elements")):
-      shutil.copyfile(os.path.join(aster_dir,"elements"),"elem.1")
+    elements_file = ""
+    if os.path.exists(os.path.join(aster_dir,"share", "aster", "elements")):
+      elements_file = os.path.join(aster_dir,"elements")
+    elif os.path.exists(os.path.join(aster_dir,"elements")):
+      elements_file = os.path.join(aster_dir,"elements")
     else:
-      shutil.copyfile(os.path.join(aster_dir,"catobj","elements"),"elem.1")
+      elements_file = os.path.join(aster_dir,"catobj","elements")
+    shutil.copyfile(elements_file,"elem.1")
+    
 
   def init_service(self,service):
 ${initservice}
@@ -325,11 +330,11 @@ AC_ARG_WITH(aster,
       [AC_HELP_STRING([--with-aster=DIR],[root directory path of Aster installation])],
       [ASTER_DIR="$withval"],[ASTER_DIR=""])
 
-if test -f ${ASTER_DIR}/asteru ; then
+if test -f ${ASTER_DIR}/bin/aster ; then
    Aster_ok=yes
    AC_MSG_RESULT(Using Aster distribution in ${ASTER_DIR})
 
-   ASTER_INCLUDES=-I$ASTER_DIR/bibc/include
+   ASTER_INCLUDES=-I$ASTER_DIR/include/aster
 
    AC_SUBST(ASTER_DIR)
    AC_SUBST(ASTER_INCLUDES)