Back to index

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

Classes

class  ParseError
class  Component
class  Resource

Functions

def get_hostname
def main

Variables

tuple appli_local = os.path.realpath(os.path.dirname(__file__))
tuple APPLI = getAppliPath.relpath(appli_local,os.path.realpath(os.getenv('HOME')))
string usage

Function Documentation

Definition at line 77 of file update_catalogs.py.

00077 
00078 def get_hostname():
00079   return socket.gethostname().split('.')[0]

Here is the caller graph for this function:

Definition at line 208 of file update_catalogs.py.

00208 
00209 def main():
00210   parser = optparse.OptionParser(usage=usage)
00211 
00212   options, args = parser.parse_args()
00213 
00214   if not os.path.exists(catalog_file_base):
00215     print "ERROR: the base catalog file %s is mandatory" % catalog_file_base
00216     sys.exit(1)
00217 
00218   #Parse CatalogResource.xml
00219   doc = etree_.parse(catalog_file_base)
00220 
00221   rootNode = doc.getroot()
00222   if rootNode.tag != "resources":
00223     raise  ParseError("First level tag must be resources not %s" % rootNode.tag)
00224 
00225   resources=[]
00226 
00227   #Extract resources
00228   for child in rootNode:
00229     if child.tag != "machine":
00230       raise  ParseError("Second level tag must be machine not %s" % child.tag)
00231     resources.append(Resource(child))
00232 
00233   # Remove remote_catalogs directory and create a new empty one
00234   if os.path.exists(cata_dir):
00235     if os.path.exists(cata_dir_bak):
00236       shutil.rmtree(cata_dir_bak)
00237     os.rename(cata_dir,cata_dir_bak)
00238 
00239   os.mkdir(cata_dir)
00240 
00241   #Get catalogs from remote resources and copy them in remote_catalogs
00242   for mach in resources:
00243     mach.get_catalogs()
00244 
00245   #Get the list of SALOME components that are defined in catalogs
00246   for mach in resources:
00247     mach.get_components()
00248 
00249   #Update the resource catalog dom object for further dump
00250   for mach in resources:
00251     mach.update()
00252 
00253   #dump new CatalogResources.xml
00254   f=open(catalog_file,'w')
00255   f.write('<?xml version="1.0" ?>\n')
00256   doc.write(f)
00257   f.write('\n')
00258   f.close()
00259   print "%s updated" % catalog_file
00260 
00261   #update configRemote.sh in env.d directory (environment variable SALOME_CATALOGS_PATH)
00262   path=[]
00263   for mach in resources:
00264     if mach.resource_dir:
00265       path.append(mach.resource_dir)
00266 
00267   f=open(os.path.join(appli_local,"env.d","configRemote.sh"),'w')
00268   f.write("export SALOME_CATALOGS_PATH=%s\n" % SEP.join(path))
00269   f.close()
00270 


Variable Documentation

tuple update_catalogs.APPLI = getAppliPath.relpath(appli_local,os.path.realpath(os.getenv('HOME')))

Definition at line 32 of file update_catalogs.py.

tuple update_catalogs.appli_local = os.path.realpath(os.path.dirname(__file__))

Definition at line 31 of file update_catalogs.py.

Initial value:
00001 """usage: %prog [options]
00002 Typical use is:
00003   python update_catalogs.py
00004 
00005 You need to have a well installed SALOME application with a CatalogResources.base.xml file.
00006 This file is used (parsed) to collect all module catalogs from distant resources and
00007 put them in the directory "remote_catalogs" with sub-directories with same name as the distant resource.
00008 Distant resources are all the resources except the main SALOME application.
00009 Module catalogs from distant resources are copied by the remote protocol declared in the catalog (rcp or rsh)
00010 except for the user resources on the local machine (local copy: cp).
00011 
00012 In a second time, this procedure generates a ready to use CatalogResources.xml with all available components
00013 for each resource.
00014 """

Definition at line 34 of file update_catalogs.py.