Back to index

salome-kernel  6.5.0
Classes | Functions | Variables
appli_gen Namespace Reference

Classes

class  xml_parser
class  params

Functions

def makedirs
def install
def main

Variables

string usage
string appli_tag = "application"
string prereq_tag = "prerequisites"
string modules_tag = "modules"
string module_tag = "module"
string samples_tag = "samples"
string resources_tag = "resources"
string nam_att = "name"
string path_att = "path"
string gui_att = "gui"

Class Documentation

class appli_gen::params

Definition at line 136 of file appli_gen.py.


Function Documentation

def appli_gen.install (   prefix,
  config_file,
  verbose = 0 
)

Definition at line 150 of file appli_gen.py.

00150 
00151 def install(prefix,config_file,verbose=0):
00152     home_dir=os.path.abspath(os.path.expanduser(prefix))
00153     filename=os.path.abspath(os.path.expanduser(config_file))
00154     _config={}
00155     try:
00156         p = xml_parser(filename)
00157         _config = p.config
00158     except xml.sax.SAXParseException, inst:
00159         print inst.getMessage()
00160         print "Configure parser: parse error in configuration file %s" % filename
00161         pass
00162     except xml.sax.SAXException, inst:
00163         print inst.args
00164         print "Configure parser: error in configuration file %s" % filename
00165         pass
00166     except:
00167         print "Configure parser: Error : can not read configuration file %s, check existence and rights" % filename
00168         pass
00169 
00170     if verbose:
00171         for cle in _config.keys():
00172             print cle, _config[cle]
00173             pass
00174 
00175     for module in _config["modules"]:
00176         print "--- add module ", module, _config[module]
00177         options = params()
00178         options.verbose=verbose
00179         options.clear=0
00180         options.prefix=home_dir
00181         options.module=_config[module]
00182         virtual_salome.link_module(options)
00183         pass
00184 
00185     appliskel_dir=os.path.join(home_dir,'bin','salome','appliskel')
00186 
00187     for fn in ('envd',
00188                'getAppliPath.py',
00189                'searchFreePort.sh',
00190                'runRemote.sh',
00191                'runAppli',
00192                'runConsole',
00193                'runSession',
00194                'runSalomeScript',
00195                'runTests',
00196                'update_catalogs.py',
00197                'kill_remote_containers.py',
00198                '.bashrc',
00199                ):
00200         virtual_salome.symlink("./bin/salome/appliskel/"+fn,os.path.join(home_dir, fn))
00201         pass
00202 
00203     if filename != os.path.join(home_dir,"config_appli.xml"):
00204         command = "cp -p " + filename + ' ' + os.path.join(home_dir,"config_appli.xml")
00205         os.system(command)
00206         pass
00207 
00208     virtual_salome.mkdir(os.path.join(home_dir,'env.d'))
00209     if os.path.isfile(_config["prereq_path"]):
00210         command='cp -p ' + _config["prereq_path"] + ' ' + os.path.join(home_dir,'env.d','envProducts.sh')
00211         os.system(command)
00212         pass
00213     else:
00214         print "WARNING: prerequisite file does not exist"
00215         pass
00216 
00217     #environment file: configSalome.sh
00218     f =open(os.path.join(home_dir,'env.d','configSalome.sh'),'w')
00219     for module in _config["modules"]:
00220         command='export '+ module + '_ROOT_DIR=${HOME}/${APPLI}\n'
00221         f.write(command)
00222         pass
00223     if _config.has_key("samples_path"):
00224         command='export DATA_DIR=' + _config["samples_path"] +'\n'
00225         f.write(command)
00226         pass
00227     if _config.has_key("resources_path") and os.path.isfile(_config["resources_path"]):
00228         command='export USER_CATALOG_RESOURCES_FILE=' + os.path.abspath(_config["resources_path"]) +'\n'
00229         f.write(command)
00230 
00231     f.close()
00232 
00233 
00234     #environment file: configGUI.sh
00235     f =open(os.path.join(home_dir,'env.d','configGUI.sh'),'w')
00236     command = """export SalomeAppConfig=${HOME}/${APPLI}
00237 export SUITRoot=${HOME}/${APPLI}/share/salome
00238 export DISABLE_FPE=1
00239 export MMGT_REENTRANT=1
00240 """
00241     f.write(command)
00242     f.close()
00243 
00244     #SalomeApp.xml file
00245     f =open(os.path.join(home_dir,'SalomeApp.xml'),'w')
00246     command="""<document>
00247   <section name="launch">
00248     <!-- SALOME launching parameters -->
00249     <parameter name="gui"        value="yes"/>
00250     <parameter name="splash"     value="yes"/>
00251     <parameter name="file"       value="no"/>
00252     <parameter name="key"        value="no"/>
00253     <parameter name="interp"     value="no"/>
00254     <parameter name="logger"     value="no"/>
00255     <parameter name="xterm"      value="no"/>
00256     <parameter name="portkill"   value="no"/>
00257     <parameter name="killall"    value="no"/>
00258     <parameter name="noexcepthandler"  value="no"/>
00259     <parameter name="modules"    value="%s"/>
00260     <parameter name="pyModules"  value=""/>
00261     <parameter name="embedded"   value="SalomeAppEngine,study,cppContainer,registry,moduleCatalog"/>
00262     <parameter name="standalone" value="pyContainer"/>
00263   </section>
00264 </document>
00265 """
00266     mods=[]
00267     #Keep all modules except KERNEL and GUI
00268     for m in _config["modules"]:
00269       if m in ("KERNEL","GUI"):continue
00270       mods.append(m)
00271     f.write(command % ",".join(mods))
00272     f.close()
00273 
00274     #Add default CatalogResources.xml file
00275     f =open(os.path.join(home_dir,'CatalogResources.xml'),'w')
00276     command="""<!DOCTYPE ResourcesCatalog>
00277 <resources>
00278    <machine name="localhost"
00279             hostname="localhost" />
00280 </resources>
00281 """
00282     f.write(command)
00283     f.close()
00284 
00285     #Add USERS directory with 777 permission to store users configuration files
00286     users_dir=os.path.join(home_dir,'USERS')
00287     makedirs(users_dir)
00288     os.chmod(users_dir, 0777)

Here is the call graph for this function:

Here is the caller graph for this function:

def appli_gen.main ( )

Definition at line 289 of file appli_gen.py.

00289 
00290 def main():
00291     parser = optparse.OptionParser(usage=usage)
00292 
00293     parser.add_option('--prefix', dest="prefix", default='.',
00294                       help="Installation directory (default .)")
00295 
00296     parser.add_option('--config', dest="config", default='config_appli.xml',
00297                       help="XML configuration file (default config_appli.xml)")
00298 
00299     parser.add_option('-v', '--verbose', action='count', dest='verbose',
00300                       default=0, help="Increase verbosity")
00301 
00302     options, args = parser.parse_args()
00303     if not os.path.exists(options.config):
00304       print "ERROR: config file %s does not exist. It is mandatory." % options.config
00305       sys.exit(1)
00306 
00307     install(prefix=options.prefix,config_file=options.config,verbose=options.verbose)
00308     pass
00309 
00310 # -----------------------------------------------------------------------------

Here is the call graph for this function:

def appli_gen.makedirs (   namedir)

Definition at line 141 of file appli_gen.py.

00141 
00142 def makedirs(namedir):
00143   if os.path.exists(namedir):
00144     dirbak=namedir+".bak"
00145     if os.path.exists(dirbak):
00146       shutil.rmtree(dirbak)
00147     os.rename(namedir,dirbak)
00148     os.listdir(dirbak) #sert seulement a mettre a jour le systeme de fichier sur certaines machines
00149   os.makedirs(namedir)

Here is the caller graph for this function:


Variable Documentation

string appli_gen.appli_tag = "application"

Definition at line 42 of file appli_gen.py.

string appli_gen.gui_att = "gui"

Definition at line 52 of file appli_gen.py.

string appli_gen.module_tag = "module"

Definition at line 45 of file appli_gen.py.

string appli_gen.modules_tag = "modules"

Definition at line 44 of file appli_gen.py.

string appli_gen.nam_att = "name"

Definition at line 50 of file appli_gen.py.

string appli_gen.path_att = "path"

Definition at line 51 of file appli_gen.py.

string appli_gen.prereq_tag = "prerequisites"

Definition at line 43 of file appli_gen.py.

string appli_gen.resources_tag = "resources"

Definition at line 47 of file appli_gen.py.

string appli_gen.samples_tag = "samples"

Definition at line 46 of file appli_gen.py.

Initial value:
00001 """usage: %prog [options]
00002 Typical use is:
00003   python appli_gen.py
00004 Typical use with options is:
00005   python appli_gen.py --verbose --prefix=<install directory> --config=<configuration file>
00006 """

Definition at line 28 of file appli_gen.py.