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

Module amazons3

source code

Synchonizes a local directory with an Amazon S3 bucket.

No configuration is required; all necessary information is taken from the command-line. The only thing configuration would help with is the path resolver interface, and it doesn't seem worth it to require configuration just to get that.


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

Classes [hide private]
  Options
Class representing command-line options for the cback-amazons3-sync script.
Functions [hide private]
 
cli()
Implements the command-line interface for the cback-amazons3-sync script.
source code
 
_usage(fd=sys.stdout)
Prints usage information for the cback-amazons3-sync script.
source code
 
_version(fd=sys.stdout)
Prints version information for the cback script.
source code
 
_diagnostics(fd=sys.stdout)
Prints runtime diagnostics information.
source code
 
_executeAction(options)
Implements the guts of the cback-amazons3-sync tool.
source code
 
_buildSourceFiles(sourceDir)
Build a list of files in a source directory
source code
 
_checkSourceFiles(sourceDir, sourceFiles)
Check source files, trying to guess which ones will have encoding problems.
source code
 
_synchronizeBucket(sourceDir, s3BucketUrl)
Synchronize a local directory to an Amazon S3 bucket.
source code
 
_verifyBucketContents(sourceDir, sourceFiles, s3BucketUrl)
Verify that a source directory is equivalent to an Amazon S3 bucket.
source code
Variables [hide private]
  logger = logging.getLogger("CedarBackup2.log.tools.amazons3")
  AWS_COMMAND = ['aws']
  SHORT_SWITCHES = 'hVbql:o:m:OdsDvw'
  LONG_SWITCHES = ['help', 'version', 'verbose', 'quiet', 'logfi...
  __package__ = 'CedarBackup2.tools'
Function Details [hide private]

cli()

source code 

Implements the command-line interface for the cback-amazons3-sync script.

Essentially, this is the "main routine" for the cback-amazons3-sync 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.7
  • 2: Error processing command-line arguments
  • 3: Error configuring logging
  • 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.

_usage(fd=sys.stdout)

source code 

Prints usage information for the cback-amazons3-sync script.

Parameters:
  • fd - File descriptor used to print information.

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

_version(fd=sys.stdout)

source code 

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.

_diagnostics(fd=sys.stdout)

source code 

Prints runtime diagnostics information.

Parameters:
  • fd - File descriptor used to print information.

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

_executeAction(options)

source code 

Implements the guts of the cback-amazons3-sync tool.

Parameters:
  • options (Options object.) - Program command-line options.
Raises:
  • Exception - Under many generic error conditions

_buildSourceFiles(sourceDir)

source code 

Build a list of files in a source directory

Parameters:
  • sourceDir - Local source directory
Returns:
FilesystemList with contents of source directory

_checkSourceFiles(sourceDir, sourceFiles)

source code 

Check source files, trying to guess which ones will have encoding problems.

Parameters:
  • sourceDir - Local source directory
  • sourceDir - Local source directory
Raises:

_synchronizeBucket(sourceDir, s3BucketUrl)

source code 

Synchronize a local directory to an Amazon S3 bucket.

Parameters:
  • sourceDir - Local source directory
  • s3BucketUrl - Target S3 bucket URL

_verifyBucketContents(sourceDir, sourceFiles, s3BucketUrl)

source code 

Verify that a source directory is equivalent to an Amazon S3 bucket.

Parameters:
  • sourceDir - Local source directory
  • sourceFiles - Filesystem list containing contents of source directory
  • s3BucketUrl - Target S3 bucket URL

Variables Details [hide private]

LONG_SWITCHES

Value:
['help',
 'version',
 'verbose',
 'quiet',
 'logfile=',
 'owner=',
 'mode=',
 'output',
...