Package CedarBackup2 :: Package tools :: Module span
[show private | hide private]
[frames | no frames]

Module CedarBackup2.tools.span

Spans staged data among multiple discs

This is the Cedar Backup span tool. It is intended for use by people who stage more data than can fit on a single disc. It allows a user to split staged data among more than one disc. It can't be an extension because it requires user input when switching media.

Most configuration is taken from the Cedar Backup configuration file, specifically the store section. A few pieces of configuration are taken directly from the user.

Author: Kenneth J. Pronovici <pronovic@ieee.org>

Classes
SpanOptions Tool-specific command-line options.

Function Summary
  cli()
Implements the command-line interface for the cback-span script.
  _consistencyCheck(config, fileList)
Runs a consistency check against media in the backup device.
  _executeAction(options, config)
Implements the guts of the cback-span tool.
  _findDailyDirs(stagingDir)
Returns a list of all daily staging directories that have not yet been stored.
  _getChoiceAnswer(prompt, default, validChoices)
Get a particular choice from the user.
  _getFloat(prompt, default)
Get a floating point number from the user.
  _getReturn(prompt)
Get a return key from the user.
  _getWriter(config)
Gets a writer and media capacity from store configuration.
  _getYesNoAnswer(prompt, default)
Get a yes/no answer from the user.
  _usage(fd)
Prints usage information for the cback script.
  _version(fd)
Prints version information for the cback script.
  _writeDisc(config, writer, spanItem)
Writes a span item to disc.

Variable Summary
Logger logger = <logging.Logger instance at 0x403ed22c>

Function Details

cli()

Implements the command-line interface for the cback-span script.

Essentially, this is the "main routine" for the cback-span script. It does all of the argument processing for the script, and then also implements the tool functionality.

This function looks pretty similiar to CedarBackup2.cli.cli(). It's not easy to refactor this code to make it reusable and also readable, so I've decided to just live with the duplication.

A different error code is returned for each type of failure:
  • 1: The Python interpreter version is < 2.3
  • 2: Error processing command-line arguments
  • 3: Error configuring logging
  • 4: Error parsing indicated configuration file
  • 5: Backup was interrupted with a CTRL-C or similar
  • 6: Error executing other parts of the script
Returns:
Error code as described above.

Note: This script uses print rather than logging to the INFO level, because it is interactive. Underlying Cedar Backup functionality uses the logging mechanism exclusively.

_consistencyCheck(config, fileList)

Runs a consistency check against media in the backup device.

The function mounts the device at a temporary mount point in the working directory, and then compares the passed-in file list's digest map with the one generated from the disc. The two lists should be identical.

If no exceptions are thrown, there were no problems with the consistency check.
Parameters:
config - Config object.
fileList - BackupFileList whose contents to check against
Raises:
ValueError - If the check fails
IOError - If there is a problem working with the media.

Warning: The implementation of this function is very UNIX-specific.

_executeAction(options, config)

Implements the guts of the cback-span tool.
Parameters:
options - Program command-line options.
           (type=SpanOptions object.)
config - Program configuration.
           (type=Config object.)
Raises:
Exception - Under many generic error conditions

_findDailyDirs(stagingDir)

Returns a list of all daily staging directories that have not yet been stored.

The store indicator file cback.store will be written to a daily staging directory once that directory is written to disc. So, this function looks at each daily staging directory within the configured staging directory, and returns a list of those which do not contain the indicator file.

Returned is a tuple containing two items: a list of daily staging directories, and a BackupFileList containing all files among those staging directories.
Parameters:
stagingDir - Configured staging directory
Returns:
Tuple (staging dirs, backup file list)

_getChoiceAnswer(prompt, default, validChoices)

Get a particular choice from the user. The default will be placed at the end of the prompt. The function loops until getting a valid choice. A blank (empty) response results in the default.
Parameters:
prompt - Prompt to show.
default - Default to set if the result is None or blank.
validChoices - List of valid choices (strings)
Returns:
Valid choice from user.

_getFloat(prompt, default)

Get a floating point number from the user. The default will be placed at the end of the prompt. The function loops until getting a valid floating point number. A blank (empty) response results in the default.
Parameters:
prompt - Prompt to show.
default - Default to set if the result is None or blank.
Returns:
Floating point number from user

_getReturn(prompt)

Get a return key from the user.
Parameters:
prompt - Prompt to show.

_getWriter(config)

Gets a writer and media capacity from store configuration. Returned is a writer and a media capacity in bytes.
Parameters:
config - Cedar Backup configuration
Returns:
Tuple of (writer, mediaCapacity)

_getYesNoAnswer(prompt, default)

Get a yes/no answer from the user. The default will be placed at the end of the prompt. A "Y" or "y" is considered yes, anything else no. A blank (empty) response results in the default.
Parameters:
prompt - Prompt to show.
default - Default to set if the result is blank
Returns:
Boolean true/false corresponding to Y/N

_usage(fd=<epydoc.imports._DevNull instance at 0x401ff88c>)

Prints usage information for the cback script.
Parameters:
fd - File descriptor used to print information.

Note: The fd is used rather than print to facilitate unit testing.

_version(fd=<epydoc.imports._DevNull instance at 0x401ff88c>)

Prints version information for the cback script.
Parameters:
fd - File descriptor used to print information.

Note: The fd is used rather than print to facilitate unit testing.

_writeDisc(config, writer, spanItem)

Writes a span item to disc.
Parameters:
config - Cedar Backup configuration
writer - Writer to use
spanItem - Span item to write

Variable Details

logger

Type:
Logger
Value:
<logging.Logger instance at 0x403ed22c>                                

Generated by Epydoc 2.1 on Thu Mar 29 20:58:29 2007 http://epydoc.sf.net