Package wsatools :: Module FitsToDb :: Class DbUpdater
[hide private]

Class DbUpdater

source code


Base class to define generic post-curation database update activities. Call getFileList() to prepare the list of files to read / records to update, then call updateDb() on each file/record to update its entry in the db. updateDb() should be overridden by classes that inherit this class. To modify the file/record list in daughter classes please see documentation of the method _getRecordsList(). If further initialisation needs to be performed before determining the file list, then override _prepare().

Nested Classes [hide private]
    Nested Errors and Exceptions

Inherited from DbConnect.CuSession.CuSession: CuError

Instance Methods [hide private]
 
_onRun(self)
Update db: Prepare file list, and read the FITS files.
source code
FileError
getErrorLog(self)
Returns: The log of errors generated by this file.
source code
list(tuple)
getFileList(self)
Returns: List of records to be updated consisting of a tuple of attributes values.
source code
 
updateDb(self, mfid, fitsFile=None, filePathName=None)
Update database record for this multiframe ID.
source code
list(tuple(str, int))
_getRecordsList(self)
Retrieves a list of records that need updating in the database.
source code
 
_prepare(self)
Fills the list of records that need to be updated.
source code
str
_stripServerName(self, filePathName)
Removes server name from file path returned by the database.
source code

Inherited from DbConnect.CuSession.CuSession: __del__, __init__, logBrokenFile, run

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from DbConnect.CuSession.CuSession: logException

Class Variables [hide private]
  _autoCommit = True
Should this curation task auto-commit database transactions?
  _recordAttrs = 'fileName, multiframeID'
Required standard attributes for the list of records to update.
  _recordSet = 'multiframeID > 0 AND fileName != \'none\' AND fi...
Defines the standard set of records to update.
  _recordTable = 'Multiframe'
Defines the standard table to search for records to update.
  _errorLog = FileError()
  _recordList = None
hash(x)

Inherited from DbConnect.CuSession.CuSession: archive, comment, cuEventID, cuNum, curator, eTypes, isDayStampedLog, onlyNonSurveys, onlySurveys, programme, programmeID, resultsFilePathName, shareFileID, sysc

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_onRun(self)

source code 

Update db: Prepare file list, and read the FITS files.

Overrides: DbConnect.CuSession.CuSession._onRun

getErrorLog(self)

source code 
Returns: FileError
The log of errors generated by this file.

getFileList(self)

source code 
Returns: list(tuple)
List of records to be updated consisting of a tuple of attributes values.

updateDb(self, mfid, fitsFile=None, filePathName=None)

source code 

Update database record for this multiframe ID. This method is overriden by subclasses to define their own individual database updates.

Parameters:
  • mfid - MultiframeID of database record to update. @type mfid int
  • fitsFile - Open FITS file containing the data for this mfid. @type fitsFile pyfits.HDUList
  • filePathName (str) - Full path to the FITS file.

_getRecordsList(self)

source code 

Retrieves a list of records that need updating in the database. The set is defined by DbUpdater._recordAttrs and DbUpdater._recordSet, which returns all multiframeIDs in table Multiframe for which files exist on our pixel server. Override this function and/or modify self._recordSet to produce different lists of records to update.

Returns: list(tuple(str, int))
List of records that need updating in the database, in the form (filePathName, multiframeID), with the server name stripped from the database fileName attribute.

Class Variable Details [hide private]

_recordSet

Defines the standard set of records to update.

Value:
'multiframeID > 0 AND fileName != \'none\' AND fileName NOT LIKE \'Pix\
elFileNoLongerAvailable:%\' ORDER BY multiframeID ASC'