Table of Contents

Class: MadrigalSite metadata.py

MadrigalSite is an object that provides access to Madrigal site info from the metadata.

This object provides access to all Madrigal site information in the metadata file siteTab.txt.

Usage example:

        import madrigal.metadata
        import madrigal.admin

        try:

            siteObj = madrigal.metadata.MadrigalSite()

            print siteObj.getSiteName(1)

        except madrigal.admin.MadrigalError, e:

            print e.getExceptionStr()

Non-standard Python modules used: None

MadrigalError exception thrown if:

  1. MadrigalMetadata fails to open or parse metadata file

  2. Columns expected to be ints or floats cannot be converted

Change history:

Written by Bill Rideout Nov. 9, 2001

Methods   
__init__
getSiteDocRoot
getSiteEmail
getSiteList
getSiteName
getSiteRelativeCGI
getSiteServer
  __init__ 
__init__ (
        self,
        madDB=None,
        initFile=None,
        )

__init__ initializes MadrigalSite by reading from siteTab.txt (or initFile).

Inputs: Existing MadrigalDB object, by default = None.

String representing the full path to the metadata file. Default is None, in which case file read is MadrigalDB.getMetadataDir()/siteTab.txt.

Returns: void

Affects: Initializes all the class member variables.

Exceptions: MadrigalError thrown by MadrigalMetadata if file not opened or parsed successfully.

  getSiteDocRoot 
getSiteDocRoot ( self,  siteID )

getSiteDocRoot returns the relative document root (e.g. madrigal) that matches siteID argument, or None if not found.

Inputs: siteID integer to get document root path.

Returns: the document root path that matches siteID argument, or None if not found.

Affects: None

Exceptions: MadrigalError if any item in row cannot be cast to correct format

Exceptions   
madrigal.admin.MadrigalError('Error parsing metadata row in siteTab.txt: ' + str( site ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
  getSiteEmail 
getSiteEmail ( self,  siteID )

getSiteEmail returns the site email address that matches siteID argument, or None if not found.

Inputs: siteID integer to get Site email address.

Returns: the site email address that matches siteID argument, or None if not found. To list multiple email addresses in this field separate them with semicolons (since commas are delimiters). getSiteEmail will automatically replace semicolons with commas, as required by multiple email addresses.

Affects: None

Exceptions: MadrigalError if any item in row cannot be cast to correct format

Exceptions   
madrigal.admin.MadrigalError('Error parsing metadata row in siteTab.txt: ' + str( site ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
  getSiteList 
getSiteList ( self )

getSiteList returns a list of all site ids and names.

Inputs: None.

Returns: a list of all site ids and names. Each item in the list is a tuple of the form (Site id (integer), site name (string)). Example item: (1,'Millstone')

Affects: None

Exceptions: MadrigalError if any item in row cannot be cast to correct format

Exceptions   
madrigal.admin.MadrigalError('Error in siteTab.txt parsing metadata row: ' + str( inst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
  getSiteName 
getSiteName ( self,  siteID )

getSiteName returns the site name that matches siteID argument, or None if not found.

Inputs: siteID integer to get SiteName.

Returns: the site name that matches siteID argument, or None if not found.

Affects: None

Exceptions: MadrigalError if any item in row cannot be cast to correct format

Exceptions   
madrigal.admin.MadrigalError('Error parsing metadata row in siteTab.txt: ' + str( site ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
  getSiteRelativeCGI 
getSiteRelativeCGI ( self,  siteID )

getSiteRelativeCGI returns the relative cgi path (e.g.cgi-bin/madrigal) that matches siteID argument, or None if not found.

Inputs: siteID integer to get relative cgi path.

Returns: the relative cgi path that matches siteID argument, or None if not found.

Affects: None

Exceptions: MadrigalError if any item in row cannot be cast to correct format

Exceptions   
madrigal.admin.MadrigalError('Error parsing metadata row in siteTab.txt: ' + str( site ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
  getSiteServer 
getSiteServer ( self,  siteID )

getSiteServer returns the site server (e.g., www.haystack.mit.edu) that matches siteID argument, or None if not found.

Inputs: siteID integer to get site server.

Returns: the site server that matches siteID argument, or None if not found.

Affects: None

Exceptions: MadrigalError if any item in row cannot be cast to correct format

Exceptions   
madrigal.admin.MadrigalError('Error parsing metadata row in siteTab.txt: ' + str( site ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )

Table of Contents

This document was automatically generated on Fri May 30 14:39:57 2008 by HappyDoc version r1_5