Back to index

salome-kernel  6.5.0
Public Member Functions | Public Attributes
update_catalogs.Resource Class Reference

List of all members.

Public Member Functions

def __init__
def build
def update
def get_rcp
def get_user
def get_host
def get_name
def get_appliPath
def get_catalogs
def get_components

Public Attributes

 node
 components
 resource_dir
 attrs

Detailed Description

Define a SALOME resource
   - components : the list of available components of the resource

Definition at line 89 of file update_catalogs.py.


Constructor & Destructor Documentation

def update_catalogs.Resource.__init__ (   self,
  node 
)

Definition at line 93 of file update_catalogs.py.

00093 
00094   def __init__(self,node):
00095     self.node=node
00096     self.components=[]
00097     self.resource_dir=None
00098     self.build()


Member Function Documentation

Definition at line 99 of file update_catalogs.py.

00099 
00100   def build(self):
00101     self.attrs=self.node.attrib
00102     #remove all children (components and modules)
00103     for child in list(self.node):
00104       self.node.remove(child)

Definition at line 131 of file update_catalogs.py.

00131 
00132   def get_appliPath(self):
00133     appliPath= self.node.get("appliPath")
00134     if appliPath is None:
00135       appliPath=APPLI
00136     return appliPath

Here is the caller graph for this function:

Get module catalogs file from the resource and copy them locally in remote_catalogs/<resource name>

Definition at line 137 of file update_catalogs.py.

00137 
00138   def get_catalogs(self):
00139     """Get module catalogs file from the resource and copy them locally in remote_catalogs/<resource name>"""
00140     hostname=self.get_host()
00141     appliPath= self.get_appliPath()
00142     userName = self.get_user()
00143     rcopy=self.get_rcp()
00144 
00145     resource_dir=os.path.join(cata_dir,self.get_name())
00146 
00147     if hostname == "localhost" or hostname == get_hostname() and userName == os.getenv("USER"):
00148       #local machine, use cp
00149       if appliPath[0]!='/':
00150         #relative path
00151         appliPath=os.path.join(os.getenv("HOME"),appliPath)
00152 
00153       if appliPath == appli_local:
00154         return
00155       os.mkdir(resource_dir)
00156       cata_path=os.path.join(appliPath,"share","salome","resources","*Catalog.xml")
00157       cmd="cp %s %s" % (cata_path,resource_dir)
00158       print cmd
00159       os.system(cmd)
00160       cata_path=os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml")
00161       cmd="cp %s %s" % (cata_path,resource_dir)
00162       print cmd
00163       os.system(cmd)
00164     else:
00165       #remote machine, use rcopy
00166       os.mkdir(resource_dir)
00167       cata_path=os.path.join(appliPath,"share","salome","resources","*Catalog.xml")
00168       cmd="%s %s@%s:%s %s"
00169       cmd= cmd%(rcopy,userName,hostname,cata_path,resource_dir)
00170       print cmd
00171       os.system(cmd)
00172       cata_path=os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml")
00173       cmd="%s %s@%s:%s %s"
00174       cmd= cmd%(rcopy,userName,hostname,cata_path,resource_dir)
00175       print cmd
00176       os.system(cmd)
00177 
00178     schema_cata=os.path.join(resource_dir,"*SchemaCatalog.xml")
00179     os.system("rm %s"% schema_cata)
00180 
00181     self.resource_dir=os.path.abspath(resource_dir)

Here is the call graph for this function:

Retrieve all components declared in module catalogs of the resource

Definition at line 182 of file update_catalogs.py.

00182 
00183   def get_components(self):
00184     """Retrieve all components declared in module catalogs of the resource"""
00185     appliPath= self.get_appliPath()
00186     userName = self.get_user()
00187     hostname=self.get_host()
00188     resource_dir=os.path.join(cata_dir,self.get_name())
00189     catalogs_list=glob.glob(os.path.join(resource_dir,"*Catalog.xml"))
00190 
00191     if hostname == "localhost" or hostname == get_hostname() and userName == os.getenv("USER"):
00192       #user local resource
00193       if appliPath[0]!='/':
00194         appliPath=os.path.join(os.getenv("HOME"),appliPath)
00195       if appliPath == appli_local:
00196         #main local resource: get catalogs in share/salome/resources
00197         catalogs_list=glob.glob(os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml"))
00198         catalogs_list=catalogs_list + glob.glob(os.path.join(appliPath,"share","salome","resources","*Catalog.xml"))
00199 
00200     for cata in catalogs_list:
00201       moduleName= os.path.basename(cata)[:-11]
00202       #Parse module catalog
00203       doc = etree_.parse(cata)
00204       rootNode = doc.getroot()
00205       for componentName in rootNode.findall("component-list/component/component-name"):
00206         self.components.append(Component(componentName.text,moduleName))
00207 

Here is the call graph for this function:

Definition at line 122 of file update_catalogs.py.

00122 
00123   def get_host(self):
00124     hostname= self.node.get("hostname")
00125     return hostname

Here is the caller graph for this function:

Definition at line 126 of file update_catalogs.py.

00126 
00127   def get_name(self):
00128     name= self.node.get("name")
00129     if name:return name
00130     return self.get_host()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file update_catalogs.py.

00111 
00112   def get_rcp(self):
00113     protocol= self.node.get("protocol")
00114     if protocol and protocol[0]=='s':return "scp"
00115     else:return "rcp"

Here is the caller graph for this function:

Definition at line 116 of file update_catalogs.py.

00116 
00117   def get_user(self):
00118     userName= self.node.get("userName")
00119     if not userName:
00120       userName=os.getenv('USER')
00121     return userName

Here is the caller graph for this function:

Definition at line 105 of file update_catalogs.py.

00105 
00106   def update(self):
00107     for compo in self.components:
00108       child=etree_.Element("component",name=compo.name,moduleName=compo.moduleName)
00109       child.tail="\n"
00110       self.node.append(child)


Member Data Documentation

Definition at line 100 of file update_catalogs.py.

Definition at line 95 of file update_catalogs.py.

Definition at line 94 of file update_catalogs.py.

Definition at line 96 of file update_catalogs.py.


The documentation for this class was generated from the following file: