7 from import_hook import register_name
8 from import_hook import register_pattern
11 register_pattern(lambda(x):x.endswith("_idl"))
13 register_name("omniORB")
14 register_name("CosNaming")
16 register_name("Engines")
17 register_name("SALOME")
18 register_name("SALOMEDS")
19 register_name("SALOME_ModuleCatalog")
22 # Engines, SALOME, SALOMEDS must be imported in that order because :
23 # Engines imports SALOME_Component_idl
24 # SALOME imports SALOME_Session_idl and SALOME_Exception_idl which imports SALOME_Component_idl
25 # and SALOMEDS imports SALOMEDS_idl and SALOMEDS_Attributes_idl which imports SALOME_Exception_idl
26 # If SALOME is imported before Engines, that module would not be completely imported
31 import SALOME_ModuleCatalog
32 from SALOME_utilities import MESSAGE
34 # We search all Python CORBA (omniorb) modules.
35 # A Python CORBA module has 2 associated Python packages
36 # These packages are named : <module_name> and <module_name>__POA
38 # That module is normally installed in shared_modules
39 # So we should find CORBA shared modules in ..
40 repertoire=os.path.join(os.path.dirname(__file__),'..')
44 # Add rep directory in the Python path to be able to import modules
45 listdir=glob.glob(os.path.join(rep,"*__POA"))
47 if os.path.isdir(elem):
48 # Found a directory (Python package) named *__POA
49 module__POA=os.path.basename(elem)
50 module=module__POA[:-5]
51 MESSAGE( "Import CORBA module: " + module + ".\n Directory: " + os.path.abspath(elem)[:-5] )
54 # Now we import modules found in shared_modules directory
55 r=os.path.join(rep,"shared_modules")
57 listfich=glob.glob(os.path.join(r,"*.py"))
58 MESSAGE( str(listfich) )
60 module=os.path.basename(m)[:-3]
61 MESSAGE( "Import module: " + module + ".\n Location: " + os.path.abspath(m) )
65 def init_shared_modules():
67 This function initializes shared modules that need to be
70 # Problem with omniORB : omniORB creates a C Python module named _omnipy
71 # this module has sub-modules : omni_func, ...
72 # _omnipy is quite a package but import with Python sub-interpreters does not seem to work
73 # To make it work we need to add those sub-modules in sys.modules
76 sys.modules["_omnipy.omni_func"]=_omnipy.omni_func
77 sys.modules["_omnipy.poa_func"]=_omnipy.poa_func
78 sys.modules["_omnipy.poamanager_func"]=_omnipy.poamanager_func
79 sys.modules["_omnipy.orb_func"]=_omnipy.orb_func