Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module cli |
|
The functionality in this module encapsulates the command-line interface for the cback script. The cback script itself is very short, basically just an invokation of one function implemented here. That, in turn, makes it simpler to validate the command line interface (for instance, it's easier to run pychecker against a module, and unit tests are easier, too).
The objects and functions implemented in this module are probably not useful to any code external to Cedar Backup. Anyone else implementing their own command-line interface would have to reimplement (or at least enhance) all of this anyway.Author: Kenneth J. Pronovici <pronovic@ieee.org>
Classes | |
---|---|
Options |
Class representing command-line options for the cback script. |
_ActionItem |
Class representing a single action to be executed. |
_ActionSet |
Class representing a set of actions to be executed. |
Function Summary | |
---|---|
Implements the command-line interface for the cback
script. | |
Sets up on-disk flow logging. | |
Sets up on-disk command output logging. | |
Sets up flow logging. | |
Sets up and creates logfile as needed. | |
Set up logging based on command-line options. | |
Sets up command output logging. | |
Set up the path resolver singleton based on configuration. | |
Sets up on-screen flow logging. | |
Prints usage information for the cback script. | |
Prints version information for the cback script. |
Variable Summary | |
---|---|
str |
DEFAULT_CONFIG : The default configuration file. |
str |
DEFAULT_LOGFILE : The default log file path. |
list |
DEFAULT_OWNERSHIP : Default ownership for the logfile. |
int |
DEFAULT_MODE : Default file permissions mode on the logfile. |
list |
VALID_ACTIONS : List of valid actions. |
list |
COMBINE_ACTIONS : List of actions which can be combined with other actions. |
list |
NONCOMBINE_ACTIONS : List of actions which cannot be combined with other actions. |
int |
COLLECT_INDEX = 100 |
str |
DATE_FORMAT = '%Y-%m-%dT%H:%M:%S %Z'
|
str |
DISK_LOG_FORMAT = '%(asctime)s --> [%(levelname)-7s] %(m...
|
str |
DISK_OUTPUT_FORMAT = '%(message)s'
|
Logger |
logger = <logging.Logger instance at 0x3adcefac>
|
list |
LONG_SWITCHES = ['help', 'version', 'verbose', 'quiet', ...
|
int |
PURGE_INDEX = 400 |
str |
SCREEN_LOG_FORMAT = '%(message)s'
|
_DevNull |
SCREEN_LOG_STREAM = <epydoc.imports._DevNull instance at...
|
str |
SHORT_SWITCHES = 'hVbqc:fl:o:m:Ods'
|
int |
STAGE_INDEX = 200 |
int |
STORE_INDEX = 300 |
Function Details |
---|
cli()Implements the command-line interface for the Essentially, this is the "main routine" for the cback script. It does all of the argument processing for the script, and then sets about executing the indicated actions. As a general rule, only the actions indicated on the command line will be executed. We will accept any of the standard actions and any of the configured extended actions (which makes action list verification a two- step process). The Raised exceptions always result in an immediate return. Otherwise, we generally return when all specified actions have been completed. Actions are ignored if the help, version or validate flags are set. A different error code is returned for each type of failure:
|
_setupDiskFlowLogging(flowLogger, logfile, options)Sets up on-disk flow logging.
|
_setupDiskOutputLogging(outputLogger, logfile, options)Sets up on-disk command output logging.
|
_setupFlowLogging(logfile, options)Sets up flow logging.
|
_setupLogfile(options)Sets up and creates logfile as needed. If the logfile already exists on disk, it will be left as-is, under the assumption that it was created with appropriate ownership and permissions. If the logfile does not exist on disk, it will be created as an empty file. Ownership and permissions will remain at their defaults unless user/group and/or mode are set in the options. We ignore errors setting the indicated user and group.
|
_setupLogging(options)Set up logging based on command-line options. There are two kinds of logging: flow logging and output logging.
Output logging contains information about system commands executed by
Cedar Backup, for instance the calls to By default, output logging is disabled. When the
options.quiet flag is set, flow logging is enabled at the
INFO level to the configured logfile only (i.e. no output will be sent
to the screen). If the options.verbose flag is set, flow
logging is enabled at the INFO level to both the screen and the
configured logfile. If the options.debug flag is set, flow
logging is enabled at the DEBUG level to both the screen and the
configured logfile.
|
_setupOutputLogging(logfile, options)Sets up command output logging.
|
_setupPathResolver(config)Set up the path resolver singleton based on configuration. Cedar Backup's path resolver is implemented in terms of a singleton, thePathResolverSingleton class. This
function takes options configuration, converts it into the dictionary
form needed by the singleton, and then initializes the singleton. After
that, any function that needs to resolve the path of a command can use
the singleton.
|
_setupScreenFlowLogging(flowLogger, options)Sets up on-screen flow logging.
|
_usage(fd=<epydoc.imports._DevNull instance at 0x3acbd5ec>)Prints usage information for the cback script.
|
_version(fd=<epydoc.imports._DevNull instance at 0x3acbd5ec>)Prints version information for the cback script.
|
Variable Details |
---|
DEFAULT_CONFIGThe default configuration file.
|
DEFAULT_LOGFILEThe default log file path.
|
DEFAULT_OWNERSHIPDefault ownership for the logfile.
|
DEFAULT_MODEDefault file permissions mode on the logfile.
|
VALID_ACTIONSList of valid actions.
|
COMBINE_ACTIONSList of actions which can be combined with other actions.
|
NONCOMBINE_ACTIONSList of actions which cannot be combined with other actions.
|
COLLECT_INDEX
|
DATE_FORMAT
|
DISK_LOG_FORMAT
|
DISK_OUTPUT_FORMAT
|
logger
|
LONG_SWITCHES
|
PURGE_INDEX
|
SCREEN_LOG_FORMAT
|
SCREEN_LOG_STREAM
|
SHORT_SWITCHES
|
STAGE_INDEX
|
STORE_INDEX
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Sep 4 13:49:32 2006 | http://epydoc.sf.net |