All text written to the web is produced in this class.
Methods
|
|
|
|
__dropLock
|
__dropLock ( self, filename )
__dropLock is a private helper function that drops exclusive access to filename via a locking file.
Inputs: filename = the file that exclusive access is required to.
Returns: None
Affects: Removes file filename + .LCK as a lock mechanism
Exceptions: None.
|
|
__getLock
|
__getLock ( self, filename )
__getLock is a private helper function that provides exclusive access to filename via a locking file.
Inputs: filename = the file that exclusive access is required to.
Returns: None
Affects: Writes file filename + .LCK as a lock mechanism
Exceptions: MadrigalError thrown if unable to write lock file
Notes: Will sleep for 1 second at a time, for a maximum of _MaxSleep seconds (presently 10)
if the file is not modified. After each second, it will check for the lock file to be removed
or modified. If it was modified, it resets the count to 0 sec and starts counting again. After
_MaxSleep counts it then assumes lock file is orphaned and returns. Orphaned file will be
removed when dropLock is called.
Exceptions
|
|
madrigal.admin.MadrigalError( "Unable to open " + filename + ".LCK as locking file ", None )
|
|
|
__init__
|
__init__ ( self, madDB=None )
__init__ initializes MadrigalWeb by reading from MadridalDB..
Inputs: Existing MadrigalDB object, by default = None.
Returns: void
Affects: Initializes self.__metaDir, self._logFile.
Exceptions: None.
|
|
_getDaynoFilter
|
_getDaynoFilter (
self,
seasonalStartDate,
seasonalEndDate,
)
_getDaynoFilter returns a filter str in the form dayno,<lower>,<upper>
Inputs:
seasonalStartDate - a string in form MM/DD . Assumes non-leap year.
Empty string means no filtering by seasonal start date.
seasonalStartDate - a string in form MM/DD . Assumes non-leap year.
Empty string means no filtering by seasonal end date.
|
|
createGlobalIsprintCmd
|
createGlobalIsprintCmd (
self,
language,
madrigalUrl,
parmList,
output,
user_fullname,
user_email,
user_affiliation,
start_datetime,
end_datetime,
instCode,
filterList,
kindatList,
expName,
fileDesc,
seasonalStartDate,
seasonalEndDate,
)
createGlobalIsprintCmd returns a string representing a global isprint command to run in a particular language.
Inputs:
language - which language to use. Allowed values are (python , Matlab , IDL )
madrigalUrl - url to madrigal home page where data is
parmList - ordered list of parameters requested.
output - output file name
user_fullname
user_email
user_affiliation
start_datetime - a datetime object. Reject experiments before that datetime
end_datetime - a datetime object. Reject experiments after that datetime
instCode - instrument code (integer)
filterList - a list of strings in form "mnem,lower,upper" where lower and/or upper may be empty
kindatList - a list of kindat codes. An empty list selects all kindats
expName - filter experiments by the experiment name. Matching is case insensitive and fnmatch characters * and ? are allowed.
Empty string is no filtering by experiment name.
fileDesc - filter files by the file description string. Matching is case insensitive and fnmatch characters * and ? are allowed.
Empty string is no filtering by file description.
seasonalStartDate - a string in form MM/DD . Dates before then in any year will be ignored. Assumes non-leap year.
Empty string means no filtering by seasonal start date.
seasonalEndDate - a string in form MM/DD . Dates after then in any year will be ignored. Assumes non-leap year.
Empty string means no filtering by seasonal end date.
Exceptions
|
|
ValueError, 'language %s not supported' %(str( language ) )
ValueError, 'parmList cannot be empty'
|
|
|
filterHtmlFormat
|
filterHtmlFormat ( self, madFilter )
filterHtmlFormat returns a filter formatted as an html table for display on the web.
Inputs: a madrigal filter
Returns: a filter formated as an html table for display on the web.
Affects: None.
Exceptions: None.
|
|
generateLogout
|
generateLogout (
self,
fileName,
expName,
)
generateLogout generates a java script which sends a user to the madLogin page to logout automatically.
Inputs: fileName: the madrigal file to return to
expName: the experiment name of the file to return to
Returns: a java script which sends a user to the madLogin page to logout automatically
Affects: None.
Exceptions: None.
|
|
getCgiString
|
getCgiString ( self, urlStr )
getCgiString returns a string made safe for urls by using urllib.quote
Inputs: urlStr - a url string that may contain unsafe url characters
Returns: a string as returned by urllib.quote
Affects: None.
Exceptions: None.
|
|
getCgiStringFromList
|
getCgiStringFromList ( self, list )
getCgiStringFromList returns a string based on a list with items separated by %20's
Inputs: list - a python list
Returns: a string based on list with items separated by %20's
Affects: None.
Exceptions: None.
|
|
getCookieDateOneYearAgo
|
getCookieDateOneYearAgo ( self )
getCookieDateOneYearAgo returns a string formated as per cookie standard of time one year in the past.
Inputs: none
Returns: a string formated as per cookie standard of time one year in the past. Used to set the expires
attribute of a cookie to be deleted
Affects: None
Exceptions: None.
|
|
getCookieDateOneYearAhead
|
getCookieDateOneYearAhead ( self )
getCookieDateOneYearAhead returns a string formated as per cookie standard of time one year in future.
Inputs: none
Returns: a string formated as per cookie standard of time one year in future. Used to set the expires
attribute of a cookie to be persisted.
Affects: None
Exceptions: None.
|
|
getFirstOwner
|
getFirstOwner ( self, madUserDataObj )
getFirstOwner returns the first owner name of a public directory - used by default when a new file is loaded.
Inputs: None
Returns: the first owner name of a public directory - used when a new file is loaded. Empty string if no
public directories exist.
Affects: None.
Exceptions: None.
|
|
getFirstPrivDir
|
getFirstPrivDir (
self,
madUserDataObj,
username,
)
getFirstPrivDir returns the first private directory name found - used by default when a new file is loaded.
Inputs: None
Returns: the first private directory name found - used by default when a new file is loaded. Empty string if no
public directories exist.
Affects: None.
Exceptions: None.
|
|
getFirstPubDir
|
getFirstPubDir ( self, madUserDataObj )
getFirstPubDir returns the first public directory name found - used by default when a new file is loaded.
Inputs: None
Returns: the first public directory name found - used by default when a new file is loaded. Empty string if no
public directories exist.
Affects: None.
Exceptions: None.
|
|
getFirstUserDir
|
getFirstUserDir (
self,
madUserDataObj,
username,
)
getFirstUserDir returns the first directory name found for a given user - used by default when save filter is loaded.
Inputs: None
Returns: the first directory name found owned by a given user - used by default when save filter file is loaded. Empty string if no
public directories exist.
Affects: None.
Exceptions: None.
|
|
getIntListFromStrList
|
getIntListFromStrList ( self, strList )
getIntListFromStrList returns a list containing integers given a list of integers in string form
Inputs: strList - a list a strings that can be converted to integers
Returns: a list containing integers given a list of integers in string form
Affects: None
Exceptions: MadrigalError thrown if a string in the list cannot be converted to an integer.
Exceptions
|
|
madrigal.admin.MadrigalError("Unable to convert following list to integers: " + str( strList ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getOptionAllUserDirTags
|
getOptionAllUserDirTags (
self,
madUserDataObj,
filterOwner,
dirName='',
)
getOptionAllUserDirTags outputs a series of html option tags with representing the list of all dirs owned by a user
Inputs: madUserDataObj - an object of type MadrigalUserData
filterOwner - a string representing the username of the filter owner
Returns: a string containing option tags of form <option value="<dirName> (public)"><dirName>...
where (public) or (private) is appended to value based on dir type. If dirName is passed in and
found to match, then that dir will be selected. Otherwise, the first row will be selected
Affects: None.
Exceptions: None.
|
|
getOptionFilterTags
|
getOptionFilterTags (
self,
madUserDataObj,
filterOwner,
filterDir,
filterName='',
)
getOptionFilterTags outputs a series of html option tags with representing the list of filters
Inputs: madUserDataObj - an object of type MadrigalUserData
filterOwner - a string representing the username of the filter owner
filterDir - a string representing the name of the private directory
filterName - a string representing the filter name to be selected - if blank or not found, select first
Returns: a string containing option tags of form <option value="<filterName>"><filterName>...
If a filterName is passed in and found to match, then that filter will be selected. Otherwise,
the first row will be selected
Affects: None.
Exceptions: None.
|
|
getOptionKindatListTags
|
getOptionKindatListTags (
self,
optionList,
selectedNumber=None,
)
getOptionKindatListTags outputs a series of html option tags of form <option value="<kindat num>"><kindat description>..
Inputs: optionList - a list of kindat numbers to be options
selectedNumber - the number of the item to be selected by default. If None, none selected
Returns: a string containing option tags of form <option value="<kindatt num>"><kindat description>...
Affects: None.
Exceptions: None.
|
|
getOptionKinstListTags
|
getOptionKinstListTags (
self,
optionList,
selectedNumber=None,
)
getOptionKinstListTags outputs a series of html option tags of form <option value="<kinst num>"><kinst description>..
Inputs: optionList - a list of kinst numbers to be options
selectedNumber - the number of the item to be selected by default. If None, none selected
Returns: a string containing option tags of form <option value="<kinst num>"><kinst description>...
Affects: None.
Exceptions: None.
|
|
getOptionListTags
|
getOptionListTags (
self,
optionList,
selectedNumber=None,
)
getOptionListTags outputs a series of html option tags with representing the items in a list
Inputs: optionList - a list of items to be options
selectedNumber - the number of the item to be selected by default. If None, none selected
Returns: a string containing option tags of form <option value="<item>"><item>...
Affects: None.
Exceptions: None.
|
|
getOptionMonthTags
|
getOptionMonthTags ( self, selectedMonth )
getOptionMonthTags outputs a series of html option tags with representing the months of the year
Inputs: selectedMonth - an integer (1-12) representing the month to be selected
Returns: a string containing option tags of form <option value="1">Jan<option value="2">Feb...
Affects: None.
Exceptions: None.
|
|
getOptionNumericTags
|
getOptionNumericTags (
self,
startNum,
endNum,
selectedNum,
)
getOptionTags outputs a series of html option tags with numerical values from startNum to endNum
Inputs: startNum - integer value of first option tag
endNum - integer value of last option tag
selectedNum - integer value of which tag is selected
Returns: a string containing option tags of form <option value="1">1<option value="2">2...
Affects: None.
Exceptions: None.
|
|
getOptionPrivDirTags
|
getOptionPrivDirTags (
self,
madUserDataObj,
filterOwner,
filterDir='',
)
getOptionDirTags outputs a series of html option tags with representing the list of private directories
Inputs: madUserDataObj - an object of type MadrigalUserData
filterOwner - a string representing the username of the filter owner
filterDir - a string representing the name of the private directory
Returns: a string containing option tags of form <option value="<dirName>"><dirName>...
If a filterOwner and filterDir are passed in and found to match, then that dir will be selected. Otherwise,
the first row will be selected
Affects: None.
Exceptions: None.
|
|
getOptionPubDirTags
|
getOptionPubDirTags (
self,
madUserDataObj,
filterOwner='',
filterDir='',
)
getOptionDirTags outputs a series of html option tags with representing the list of public directories
Inputs: madUserDataObj - an object of type MadrigalUserData
filterOwner - a string representing the username of the filter owner
filterDir - a string representing the name of the directory
Returns: a string containing option tags of form <option value="<userName:dirName>"><userName:dirName>...
If a filterOwner and filterDir are passed in and found to match, then that dir will be selected. Otherwise,
the first row will be selected
Affects: None.
Exceptions: None.
|
|
getRulesOfTheRoad
|
getRulesOfTheRoad ( self )
getRulesOfTheRoad returns a string giving the rules in html formal for using madrigal data.
Inputs: None
Returns: a string giving the rules in html formal for using madrigal data
Affects: None.
Exceptions: None.
|
|
getSpaceString
|
getSpaceString ( self, cgiString )
getSpaceString returns a string based on urllib.unquote
Inputs: cgiString - a string that may contain characters substituted by urllib.quote
Returns: a string possibly modified by urllib.unqoute
Affects: None.
Exceptions: None.
|
|
isTrusted
|
isTrusted ( self )
isTrusted returns 1 if browser ip matches any in the trustedIPs.txt file; 0 otherwise.
Inputs: None
Returns: 1 if browser ip matches any in the trustedIPs.txt file; 0 otherwise. Also returns
0 if no browser ip available or trustedIPs.txt cannot be opened.
Affects: None.
Exceptions: None.
|
|
logDataAccess
|
logDataAccess (
self,
fullFilenameList,
user_fullname=None,
user_email=None,
user_affiliation=None,
)
logDataAccess logs queries that access low-level data.
Records user name, email, affiliation, datetime, and full path the file(s) accessed.
Inputs:
fullFilenameList either a list of full filenames, or a string with one filename
user_fullname - if None, try to read from cookie. Also, any commas replaced by spaces.
user_email - if None, try to read from cookie. Also, any commas replaced by spaces.
user_affiliation - if None, try to read from cookie. Also, any commas replaced by spaces.
Outputs: None
Affects: Write line to log file with 5 or more comma-delimited columns. Example:
Bill Rideout,brideout@haystack.mit.edu,MIT Haystack,2002-12-25 00:00:00, /opt/madrigal/experiments/2005/mlh/01sep05/mlh050901g.001,/opt/madrigal/experiments/2005/mlh/02sep05/mlh050902g.001
Uses __getLock and __dropLock to ensure single users access to log file
|
|
outputHead
|
outputHead ( self, title )
outputHead outputs a standard html <head> with the given title
Inputs: title - string : title of cgi page
Returns: a standard html <head> with the given title. This function
also defines the "lb" class used to format buttons, so changing that
format here changes it in all madrigal python cgi pages.
Affects: None.
Exceptions: None.
|
|
outputIsprintReport
|
outputIsprintReport (
self,
madFilter,
madForm,
filename,
)
outputIsprintReport prints a isprint-formated maddata object given a madrigal filter.
Works by calling madrigal._Madrec.getIsprintReport
Inputs: 1) madFilter = the MadrigalFilter that determines all the settings.
madForm - a cgi.FieldStorage object representing the submitted form
filename = the full path to the madrigal file to use
Returns: None
Affects: prints a isprint-formated maddata object given a madrigal filter.
Exceptions: None.
Exceptions
|
|
madrigal.admin.MadrigalError( "Illegal mnemonic operator: " + mnemList [ 1 ], None )
madrigal.admin.MadrigalError( "Illegal mnemonic string: " + str( madFilter.mnemStr1 ), None )
madrigal.admin.MadrigalError( "Illegal mnemonic string: " + str( madFilter.mnemStr2 ), None )
|
|