CedarBackup2.tools.amazons3

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=<epydoc.docintrospecter._DevNull object>) Prints usage information for the cback-amazons3-sync script. | source code
_version(fd=<epydoc.docintrospecter._DevNull object>) Prints version information for the cback script. | source code
_diagnostics(fd=<epydoc.docintrospecter._DevNull object>) 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.Logger object>`
| 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=<epydoc.docintrospecter._DevNull object>) | 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=<epydoc.docintrospecter._DevNull object>) | 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=<epydoc.docintrospecter._DevNull object>) | 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: `ValueError` - If a problem file is found @see http://opensourcehacker.com/2011/09/16/fix-linux-filename-encodings-with-python/ @see http://serverfault.com/questions/82821/how-to-tell-the-language-encoding-of-a-filename-on-linux @see http://randysofia.com/2014/06/06/aws-cli-and-your-locale/

### _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',
      ...