AutoArchive._ui._cmdline

Cmdline UI component.

Package implements command-line user interface.

Modules

_user_action_executor

UserActionExecutor class.

class AutoArchive._ui.cmdline._user_action_executor.UserActionExecutor(componentUi, applicationContext, archivingApplication)[source]

Bases: object

Takes care of execution of a user action specified on the command line.

Parameters:
execute()[source]

Executes an action defined for the specified command for specified archive specification files.

Command is read from the ApplicationContext.appEnvironment.options. If options has an attribute that matches one of the CmdlineCommands and the value of that attribute is True then the action for the matching command is executed. If there is no such attribute, then the default action create is executed.

Archive specification files can be specified by following ways:

  • By archive names passed in ApplicationContext.appEnvironment.arguments.

    Archive name can not contain the string defined by ConfigConstants.ARCHIVE_SPEC_EXT at the end otherwise it would be taken as the path to an archive specification file. Archive specification files corresponding to the names are looked up in the path defined by Options.ARCHIVE_SPECS_DIR option.

  • By paths to archive specification files passed in ApplicationContext.appEnvironment.arguments.

    A path must end with the string defined by ConfigConstants.ARCHIVE_SPEC_EXT.

Returns:

True if the action execution was successful; False otherwise.

_cmdline_ui

CmdlineUi class.

class AutoArchive._ui.cmdline._cmdline_ui.CmdlineUi(appEnvironment, configuration)[source]

Bases: object

Implementation of the command-line user interface.

Provides basic methods for showing messages of various importance to a user. It uses standard output and standard error as the user interface.

Parameters:
  • appEnvironment (AppEnvironment) – Application environment.

  • configuration (IConfiguration) – Application configuration.

presentLine(line)[source]

Present a line of text to the user.

Note

The verbosity level has no effect on presenting the line.

Parameters:

line (str) – The text that shall be presented to the user.

presentMultiFieldLine(multiFieldLine)[source]

Present a line consisting of multiple fields of text to the user.

Note

The verbosity level has no effect on presenting the line.

Parameters:

multiFieldLine (MultiFieldLine) – Line that shall be presented.

setProcessingArchSpec(archSpec)[source]

Sets currently processed archive specification file.

Parameters:

archSpec (str) – The archive specification file name or path to it.

showError(msg)[source]

Show an error message to (UiMessageKinds.Error) the user.

See also: verbosity.

Parameters:

msg (str) – The message that should be shown to the user.

showInfo(msg)[source]

Show an information message (UiMessageKinds.Info) to the user.

See also: verbosity.

Parameters:

msg (str) – The message that should be shown to the user.

showNotification(msg)[source]

Show an unintrusive notification message (UiMessageKinds.Notification) to the user.

Note

If user interface implementation does not have means to support notifications then it should be presented to the user similarly as showInfo().

See also: verbosity.

Parameters:

msg (str) – The message that should be shown to the user.

showVerbose(msg)[source]

Show a verbose-type message (UiMessageKinds.Verbose) to the user.

Verbose messages should be shown only if user enables it. Although this method can be called regardless of current verbosity level, the concrete implementation can decide whether it will be shown or not if verbosity level is 0. It is not recommended to call this method if verbosity level is 0 due to performance reasons. Current verbosity level can be obtained via verbosity property.

See also: verbosity.

Parameters:

msg (str) – The message that should be shown to the user.

showWarning(msg)[source]

Show a warning message (UiMessageKinds.Warning) to the user.

See also: verbosity.

Parameters:

msg (str) – The message that should be shown to the user.

messageShown = <AutoArchive._infrastructure.py_additions.event object>
property verbosity

Gets the verbosity level.

If verbosity level is VerbosityLevels.Quiet only messages of kind UiMessageKinds.Error are shown. For level VerbosityLevels.Normal all messages kinds except UiMessageKinds.Verbose are shown. For level VerbosityLevels.Verbose all message kinds are shown.

Return type:

VerbosityLevels

_cmdline_commands

CmdlineCommands and _CmdlineCommandsUtils static classes.

class AutoArchive._ui.cmdline._cmdline_commands.CmdlineCommands[source]

Bases: object

Constants for command-line command names.

Command-line commands are used to invoke program operations via a command-line argument. For example: --create will invoke a backup creation.

Note

It is not allowed to change values of these constants.

CREATE = 'create'

Create backup for a given archive specification file.

LIST = 'list'

List all archive specification files.

PURGE = 'purge'

Purge orphaned archive data.

class AutoArchive._ui.cmdline._cmdline_commands._CmdlineCommandsUtils[source]

Bases: object

Various utility methods working with CmdlineCommands.

static getAllCommands()[source]

Iterator over all known commands.

Returns:

All options defined in CmdlineCommands.

Return type:

Iterable<str>

classmethod isExistingCommand(commandName)[source]

Check whether a command with name commandName does exists in _CmdlineCommandsUtils.

Parameters:

commandName (str) – Name of the command which existence shall be checked.

Returns:

True if option with name commandName exists; False otherwise.

Return type:

bool