Back to index

nordugrid-arc-nox  1.1.0~rc6
Namespaces | Functions
arcom Namespace Reference

Namespaces

namespace  client
namespace  logger
namespace  security
namespace  service
namespace  store
namespace  threadpool
namespace  xmltree

Functions

def import_class_from_string
def get_attributes
def get_child_nodes
def get_child_values_by_name
def datapoint_from_url
def parse_url

Function Documentation

def arcom.datapoint_from_url (   url_string,
  ssl_config = None 
)

Definition at line 63 of file __init__.py.

00063 
00064 def datapoint_from_url(url_string, ssl_config = None):
00065     import arc
00066     user_config = arc.UserConfig(arc.initializeCredentialsType(arc.initializeCredentialsType.SkipCredentials))
00067     if ssl_config:
00068         if ssl_config.has_key('key_file'): user_config.KeyPath(ssl_config['key_file'])
00069         if ssl_config.has_key('cert_file'): user_config.CertificatePath(ssl_config['cert_file'])
00070         if ssl_config.has_key('proxy_file'): user_config.ProxyPath(ssl_config['proxy_file'])
00071         if ssl_config.has_key('ca_file'): user_config.CACertificatePath(ssl_config['ca_file'])
00072         if ssl_config.has_key('ca_dir'): user_config.CACertificatesDirectory(ssl_config['ca_dir'])
00073     url = arc.URL(url_string)
00074     handle = arc.DataHandle(url, user_config)
00075     point = handle.__ref__()
00076     # possible memory leaks - TODO: investigate
00077     url.thisown = False
00078     user_config.thisown = False
00079     handle.thisown = False
00080     return point
00081 
00082 # for the URL class

Here is the caller graph for this function:

def arcom.get_attributes (   node)

Definition at line 17 of file __init__.py.

00017 
00018 def get_attributes(node):
00019     return dict([(attribute.Name(), str(attribute)) for attribute in [node.Attribute(i) for i in range(node.AttributesSize())]])

def arcom.get_child_nodes (   node)
Get all the children nodes of an XMLNode

get_child_nodes(node)

node is the XMLNode whose children we need

Definition at line 20 of file __init__.py.

00020 
00021 def get_child_nodes(node):
00022     """ Get all the children nodes of an XMLNode
00023     
00024     get_child_nodes(node)
00025     
00026     node is the XMLNode whose children we need
00027     """
00028     # the node.Size() method returns the number of children
00029     return [node.Child(i) for i in range(node.Size())]

Here is the caller graph for this function:

def arcom.get_child_values_by_name (   node,
  name 
)
Get the non-empty children nodes with a given name.

get_child_values_by_name(node, name):

node is the XMLNode whose children we need
name is the name of the children we need

e.g.
In [23]: print x.GetXML()
<Service name="pythonservice" id="librarian">
    <ClassName>storage.librarian.librarian.LibrarianService</ClassName>
    <ISISURL>https://localhost:60000/ISIS1</ISISURL>
    <ISISURL>https://localhost:60000/ISIS2</ISISURL>
    <ISISURL/>
    <ISISURL/>
    <ISISURL/>
    <HeartbeatTimeout>60</HeartbeatTimeout>
    <CheckPeriod>20</CheckPeriod>
    <ClientSSLConfig>
        <KeyPath>/etc/grid-security/hostkey.pem</KeyPath>
        <CertificatePath>/etc/grid-security/hostcert.pem</CertificatePath>
        <CACertificatesDir>/etc/grid-security/certificates</CACertificatesDir>
    </ClientSSLConfig>
</Service>

In [24]: get_child_values_by_name(x,'ISISURL')
Out[24]: ['https://localhost:60000/ISIS1', 'https://localhost:60000/ISIS2']    

Definition at line 30 of file __init__.py.

00030 
00031 def get_child_values_by_name(node, name):
00032     """ Get the non-empty children nodes with a given name.
00033     
00034     get_child_values_by_name(node, name):
00035     
00036     node is the XMLNode whose children we need
00037     name is the name of the children we need
00038     
00039     e.g.
00040     In [23]: print x.GetXML()
00041     <Service name="pythonservice" id="librarian">
00042         <ClassName>storage.librarian.librarian.LibrarianService</ClassName>
00043         <ISISURL>https://localhost:60000/ISIS1</ISISURL>
00044         <ISISURL>https://localhost:60000/ISIS2</ISISURL>
00045         <ISISURL/>
00046         <ISISURL/>
00047         <ISISURL/>
00048         <HeartbeatTimeout>60</HeartbeatTimeout>
00049         <CheckPeriod>20</CheckPeriod>
00050         <ClientSSLConfig>
00051             <KeyPath>/etc/grid-security/hostkey.pem</KeyPath>
00052             <CertificatePath>/etc/grid-security/hostcert.pem</CertificatePath>
00053             <CACertificatesDir>/etc/grid-security/certificates</CACertificatesDir>
00054         </ClientSSLConfig>
00055     </Service>
00056 
00057     In [24]: get_child_values_by_name(x,'ISISURL')
00058     Out[24]: ['https://localhost:60000/ISIS1', 'https://localhost:60000/ISIS2']    
00059     """
00060     return [str(child) for child in get_child_nodes(node) if child.Name() == name and len(str(child)) > 0]  
00061 
00062 # for DataHandle and DataPoint

Here is the call graph for this function:

Import the class which name is in the string

import_class_from_string(str)

'str' is the name of the class in [package.]*module.classname format.

Definition at line 1 of file __init__.py.

00001 def import_class_from_string(str):
00002     """ Import the class which name is in the string
00003     
00004     import_class_from_string(str)
00005 
00006     'str' is the name of the class in [package.]*module.classname format.
00007     """
00008     module = '.'.join(str.split('.')[:-1]) # cut off class name
00009     cl = __import__(module) # import module
00010     for name in str.split('.')[1:]: # start from the first package name
00011         # step to the next package or the module or the class
00012         cl = getattr(cl, name)
00013     return cl # return the class
00014 
00015 # for XMLNode
00016 
def arcom.parse_url (   url)

Definition at line 83 of file __init__.py.

00083 
00084 def parse_url(url):
00085     import arc
00086     url = arc.URL(url)
00087     proto = url.Protocol()
00088     host = url.Host()
00089     port = url.Port()
00090     path = url.Path()
00091     return proto, host, int(port), path