Firebird Upkeep utility - Base classes and other definitions
fbupkeep.base.StopError¶Bases: fbupkeep.base.Error
Error that should stop furter processing.
fbupkeep.base.has_option(namespace, name: str)¶Returns True if argparse.Namespace has an option.
fbupkeep.base.ConfigOption(name: str, datatype: Any, description: str, required: bool = False, default: Any = None, proposal: Any = None)¶Bases: object
Task configuration option.
| name: | Option name. |
|---|---|
| datatype: | Option datatype [str, int, float, bool or list]. |
| description: | Option description. Can span multiple lines. |
| required: | True if option must have a value. |
| default: | Default value. |
| proposal: | Text with proposed configuration entry (if it’s different from default). |
| value: | Current option value. |
configure(config: configparser.ConfigParser, section: str) → None¶Update option value from configuration.
| config: | ConfigParser instance with configuration values. |
|---|---|
| section: | Name of ConfigParser section that should be used to get new configuration values. |
get_config() → List[T]¶Return list of text lines suitable for use in configuration file.
Each line starts comment marker ; and ends with newline. Last line is options definition.
get_printout() → str¶Return option printout in ‘name = value’ format.
validate() → None¶Checks whether required option has value other than None.
| Error: | When required option does not have a value. |
|---|
fbupkeep.base.TaskConfig(name: str = 'main')¶Bases: object
Task configuration options.
| name: | Name associated with Task Configuration [default: ‘main’]. |
|---|
add(option: fbupkeep.base.ConfigOption) → None¶Add configuration option.
add_option(name: str, datatype: Any, description: str, required: bool = False, default: bool = None, proposal: bool = False) → None¶Add new configuration option.
configure(config: configparser.ConfigParser, section: str) → None¶Update configuration.
| config: | ConfigParser instance with configuration values. |
|---|---|
| section: | Name of ConfigParser section that should be used to get new configuration values. |
get_option(name: str) → fbupkeep.base.ConfigOption¶Return ConfigOption with specified name or None.
get_printout() → List[str]¶Return list of text lines with printout of current configuration
has_option(name: str) → bool¶Return True if option with specified name is defined.
validate() → None¶Checks whether all required options have value other than None.
| Error: | When required option does not have a value. |
|---|
options¶Options dictionary (name,ConfigOption).
fbupkeep.base.LoggedObject¶Bases: object
Object with logging support.
| logger: | logging.Logger instance. |
|---|---|
| mute: | If True, only errors and exceptions are printed (to stderr). |
| log_only: | If True, all console output is suppressed. |
error(message: str) → None¶Log ERROR message and print it to stderr if not suppressed.
exception(message: str) → None¶Log ERROR message with exception information and print it to stderr if not suppressed.
info(message: str = '', end: str = '\n') → None¶Log INFO message (if present) and print the message to stdout if not suppressed.
print(message: str = '') → None¶Print the message to stdout if not suppressed.
logger¶Logger instance
fbupkeep.base.Task(executor)¶Bases: fbupkeep.base.LoggedObject
Base task.
| executor: | TaskExecutor that owns this Task instance. |
|---|---|
| name: | Task name [default: “Task”]. |
| description: | Short task description [default: None]. Should NOT span multiple lines. |
| config: | TaskConfig instance. |
| verbose: | Verbose output flag [default: False]. |
| report: | List of text lines with execution report [default: Empty list]. |
| errors: | List of text lines with execution errors [default: Empty list]. |
| timestamp: | Timestamp used for filename interpolation. |
| start: | Timestamp when task execution started (set by executor) [default: None]. |
| stop: | Timestamp when task execution ended (set by executor) [default: None]. |
configure(config: configparser.ConfigParser, options: argparse.Namespace) → List[fbupkeep.base.TaskConfig]¶Task configuration.
Updates the config attribute from upkeep_<options.job_name> config section. Validates the config.
run() → None¶Task execution. Default implementation does nothing.
fbupkeep.base.TaskExecutor¶Bases: fbupkeep.base.LoggedObject
Task executor.
| config: | TaskConfig instance. |
|---|---|
| verbose: | Verbose output flag [default: False]. |
| tasks: | List of Task instances with all installed tasks. |
get_task(name: str) → fbupkeep.base.Task¶Return task with specified name or None.
load_tasks() → None¶Load all registered tasks.
run(config: configparser.ConfigParser, options: argparse.Namespace) → None¶Run tasks.
| log_only: | Suppress all screen output. |
|---|---|
| quiet: | Suppress informational screen output, errors are still print out to stderr. |
| verbose: | Additional informational screen output. |
| dry_run: | Prepare execution but do not run tasks. Print used configuration as verbose output. |
write_default_config(cfg_file: TextIO) → None¶Write default configuration for all known tasks into file.
| cfg_file: | Openned file-like object. |
|---|
Firebird Upkeep utility - Standard tasks
fbupkeep.tasks.TaskGstat(executor)¶Bases: fbupkeep.base.Task
Task that collects gstat database statistics.
run() → None¶Task execution.
fbupkeep.tasks.TaskGbak(executor)¶Bases: fbupkeep.base.Task
Task that creates logical (gbak) database backup.
run() → None¶Task execution.
fbupkeep.tasks.TaskGbakRestore(executor)¶Bases: fbupkeep.base.Task
Task that restores database from logical (gbak) backup file.
run() → None¶Task execution.
fbupkeep.tasks.TaskSweep(executor)¶Bases: fbupkeep.base.Task
Task that performs database sweep.
run() → None¶Task execution.
fbupkeep.tasks.TaskIndexRecompute(executor)¶Bases: fbupkeep.base.Task
Task that recomputes statistics for all database indices.
run() → None¶Task execution.
fbupkeep.tasks.TaskIndexRebuild(executor)¶Bases: fbupkeep.base.Task
Task that rebuilds all user (i.e. not system) indices.
run() → None¶Task execution.
fbupkeep.tasks.TaskRemoveOld(executor)¶Bases: fbupkeep.base.Task
Task that removes old files.
configure(config: configparser.ConfigParser, options: argparse.Namespace) → None¶Task configuration.
run() → None¶Task execution.
Firebird Upkeep utility
usage:
fbupkeep [-h] [--version] [--create-config FILENAME]
[--host HOST] [-u USER] [-p PASSWORD]
[-c CONFIG] [-o DIR] [--dry-run]
[-v] [-q] [-l {critical,fatal,error,warn,warning,info,debug,notset}]
[--log-only]
job_name
| -h, --help | show this help message and exit |
| --version | show program’s version number and exit |
| --create-config FILENAME | |
| Create configuration file for job and exit (default: None) | |
| --host HOST | Server host (default: localhost) |
| -u USER, --user USER | |
| User name (default: sysdba) | |
| -p PASSWORD, --password PASSWORD | |
| User password (default: masterkey) | |
| -c CONFIG, --config CONFIG | |
| Configuration file (default: fbupkeep.cfg) | |
| -o DIR, --output-dir DIR | |
| Force directory for log files and other output (default: ${here}/${job_name}) | |
| --dry-run | Prepare execution but do not run tasks (default: False) |
| -v, --verbose | Verbose output (default: False) |
| -q, --quiet | No screen output (default: False) |
| --log-only | Suppress all screen output including error messages (default: False) |
fbupkeep.runner.main()¶Main function for fbupkeep script.