A curation session. Any data curation activity for the archive where a
log is required to be recorded, should either be designed as a class that
inherit from this class or else an instance of this class should be
invoked by that curation script. This class design ensures a log is
correctly written, errors are correctly handled, temporary files are
correctly managed and that the database ArchiveCurationHistory and
ProgrammeCurationHistory tables are updated if required. Also a database
connection, temporary working directory, and programme table objects are
provided if required.
Warning:
The destructor won't be called if the instance of a CuSession
object is copied to a member variable that stores it (if it used
only temporarily then that's OK - either the member variable uses
the reference to the CuSession temporarily or the reference to the
CuSession is passed to a temporary variable). This is because a
circular reference occurs on destruction.
Note:
In the destructor you cannot order the destruction of the archive
and log objects by just calling del. Therefore, I've left their
order of destruction undefined - the order is not important.
|
__init__(self,
programmeID='
' ,
curator=' rsc ' ,
comment=' A descriptive comment ' ,
database=' WSA ' ,
isTrialRun=False,
userName=' ldservro ' ,
cli=None)
Writes a database lock and opens a connection. |
source code
|
|
|
__del__(self)
Finalises curation session - updates the ArchiveCurationHistory and
ProgrammeCurationHistory tables, if required. |
source code
|
|
|
run(self)
Executes the _onRun() method of the curation session within a try
block, so that all the standard exceptions may be dealt with
correctly. |
source code
|
|
|
logBrokenFile(self,
fileDetails,
logFilePath=None)
Appends the details of the broken file to end of the provided log
file. |
source code
|
|
|
_onRun(self)
Curation sessions that inherit from this class should override this
method, executing within all of the tasks that required of this
curation session. |
source code
|
|
|
_onException(self)
Attempts to rollback transaction and sets the database state flags,
so that the destructor realises the curation session failed. |
source code
|
|
|
|
int
|
_getNextID(self,
attrName,
tableName,
where='
' )
Obtain next available ID number in the db for a given ID attribute. |
source code
|
|
|
_scrubACHPlaceHolder(self)
Scrubs the placeholder default row in the ArchiveCurationHistory
table, generated by _getNextCuEventID(). |
source code
|
|
|
_updateArchiveCurationHistory(self)
Adds an entry for this curation session to the ArchiveCurationHistory
database table. |
source code
|
|
|
_updateProgrammeCurationHistory(self)
Adds an entry for this curation session to the
ProgrammeCurationHistory database table. |
source code
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
_numSessions = 0
|
|
eTypes = set([ ])
Exception types trapped by any CuSession in this process.
|
|
sysc = SystemConstants()
System constants for this CuSession.
|
|
cuNum = -9999
Curation task number.
|
|
isDayStampedLog = False
Include day in log file name?
|
|
_autoCommit = False
Should this curation task auto-commit database transactions?
|
|
_cleanUpDirs = True
Always clean-up all temporary files.
|
|
_isPersistent = True
Should this curation task try to re-open broken database connections?
|
|
_reqDbLock = True
Should only a single instance of this curation task run at a time?
|
|
_reqCuEventID = False
In trial run mode is a cuEventID required?
|
|
_useWorkDir = False
Create a temporary work directory.
|
|
comment = ' A descriptive comment '
Descriptive comment as to why curation task is being performed.
|
|
curator = ' rsc '
Name of curator.
|
|
archive = None
A connection to the archive being curated (a DbSession object).
|
|
cuEventID = None
Unique ID for this curation event.
|
|
onlyNonSurveys = False
Only curate non-survey programmes?
|
|
onlySurveys = False
Only curate survey programmes?
|
|
programme = None
A DataFactory.ProgrammeTable - quick access to
Programme table data.
|
|
programmeID = None
ID, or set of IDs, of (all) the programme being curated this session.
|
|
resultsFilePathName = ' NONE '
Results file for ArchiveCurationHistory.
|
|
shareFileID = '
'
Unique ID tag for files on the catalogue load server share directory.
|
|
_cuTable = None
The DataFactory.CurationTaskTable - quick access to
CurationTask.
|
|
_lockPathName = None
Location of the database lock file.
|
|
_log = None
The curation log - an instance of a Logger
class.
|
|
_rolledBack = None
Has the CU transaction rolled-back?
|
|
_success = None
Has the programme being curated successfully?
|