escale.cli package¶
-
escale.cli.
quote_join
(words, final=' or ', join=', ', quote="'")¶ Join words.
Example:
>>> quote_join(list(range(1,4))) "'1', '2' or '3'"
Parameters: - words (list) – list of objects that implement __str__.
- final (str) – connector between the two last words.
- join (str) – connector between the first words but the last.
- quote (str or tuple) – begin and end quotes for the words.
Returns: formated sentence.
Return type: str
-
escale.cli.
debug_print
(msg)¶ Print a status message.
-
escale.cli.
multiline_print
(*lines)¶ Decorate and print a sentence.
The first letter of the first line is capitalized and a final dot is appended under some conditions.
-
escale.cli.
decorate_line
(line)¶ Capitalize the first letter.
-
escale.cli.
edit_config
(cfg_file, msgs=[])¶ Add or edit sections of a configuration file.
Parameters: - cfg_file (str) – path to a configuration file.
- msgs (list) – pending messages.
Returns: pending messages.
Return type: list
-
escale.cli.
query_local_repository
(config, section=None, msgs=[])¶ Query local repository.
Unicode is alright.
Returns: configuration option and value. Return type: (str, str)
-
escale.cli.
request_credential
(hostname=None, username=None)¶ Request credential input from the command-line.
Parameters: - hostname (str) – hostname of the remote machine that requests credential.
- username (bool or str) – username, if only the password is to be requested.
If no username information is available and only a password is desired,
can be any non-string value evaluating to
True
.
Returns: password, if only a password is requested, or (username, password).
Return type: str or (str, str)
-
class
escale.cli.
DirectController
(logger=None, maintainer=None)¶ Bases:
object
User interface controller.
Implements a few basic routines that inform the user or request information from her.
-
failure
(repository, exception, backtrace=None)¶ Log and notify client about termination on error.
-
getServerCertificate
(ssl_socket)¶ Deprecated.
-
mount
(protocol, *args)¶ Mount volumes in the file system.
-
notifyMaintainer
(exception='', backtrace='')¶ Send a notification email to the maintainer’s email address using the local SMTP server if any.
-
requestCredential
(hostname=None, username=None)¶ Request username and password.
-
restartWorker
(repository, sleep_time=None)¶ Notify client about automatic restart.
-
success
(repository, result)¶ Notify client about task completion.
-
umount
(protocol, *args)¶ Mount volumes from the file system.
-
-
class
escale.cli.
UIController
(lock=<Lock(owner=None)>, queue=<multiprocessing.queues.Queue object>, logger=None, parent=None, maintainer=None)¶ Bases:
escale.log.log.Listener
,escale.cli.controller.DirectController
Thread-safe version of a user interface controller.
A “parent” UIController should run in the main thread while each worker thread or subprocess runs a proxy UIController that relays all the calls to the “parent” controller.
-
failure
(*args)¶ Log and notify client about termination on error.
-
mount
(*args)¶ Mount volumes in the file system.
-
requestCredential
(hostname=None, username=None)¶ Request username and password.
-
success
(*args)¶ Notify client about task completion.
-
umount
(*args)¶ Mount volumes from the file system.
-
escale.cli.format module¶
-
escale.cli.format.
debug_print
(msg)¶ Print a status message.
-
escale.cli.format.
decorate_line
(line)¶ Capitalize the first letter.
-
escale.cli.format.
decorate_paragraph
(*lines)¶ Decorate a multi-line sentence.
The first letter of the first line is capitalized and a final dot is appended under some conditions.
-
escale.cli.format.
multiline_print
(*lines)¶ Decorate and print a sentence.
The first letter of the first line is capitalized and a final dot is appended under some conditions.
escale.cli.auth module¶
-
escale.cli.auth.
request_credential
(hostname=None, username=None)¶ Request credential input from the command-line.
Parameters: - hostname (str) – hostname of the remote machine that requests credential.
- username (bool or str) – username, if only the password is to be requested.
If no username information is available and only a password is desired,
can be any non-string value evaluating to
True
.
Returns: password, if only a password is requested, or (username, password).
Return type: str or (str, str)
escale.cli.controller module¶
-
class
escale.cli.controller.
DirectController
(logger=None, maintainer=None)¶ Bases:
object
User interface controller.
Implements a few basic routines that inform the user or request information from her.
-
error_file
¶
-
failure
(repository, exception, backtrace=None)¶ Log and notify client about termination on error.
-
getServerCertificate
(ssl_socket)¶ Deprecated.
-
mount
(protocol, *args)¶ Mount volumes in the file system.
-
notifyMaintainer
(exception='', backtrace='')¶ Send a notification email to the maintainer’s email address using the local SMTP server if any.
-
requestCredential
(hostname=None, username=None)¶ Request username and password.
-
restartWorker
(repository, sleep_time=None)¶ Notify client about automatic restart.
-
success
(repository, result)¶ Notify client about task completion.
-
umount
(protocol, *args)¶ Mount volumes from the file system.
-
-
class
escale.cli.controller.
UIController
(lock=<Lock(owner=None)>, queue=<multiprocessing.queues.Queue object>, logger=None, parent=None, maintainer=None)¶ Bases:
escale.log.log.Listener
,escale.cli.controller.DirectController
Thread-safe version of a user interface controller.
A “parent” UIController should run in the main thread while each worker thread or subprocess runs a proxy UIController that relays all the calls to the “parent” controller.
-
abort
()¶
-
conn
¶
-
failure
(*args)¶ Log and notify client about termination on error.
-
mount
(*args)¶ Mount volumes in the file system.
-
requestCredential
(hostname=None, username=None)¶ Request username and password.
-
success
(*args)¶ Notify client about task completion.
-
umount
(*args)¶ Mount volumes from the file system.
-
escale.cli.ctl module¶
-
escale.cli.ctl.
access
(modifiers=None, resource=None, repository=None)¶ Get or set access modifiers of a resource.
-
escale.cli.ctl.
backup
(repository=None, archive=None, fast=None)¶ Store a full relay repository in an archive.
-
escale.cli.ctl.
clear_cache
(repository=None, prefix='cc')¶ Remove caches.
-
escale.cli.ctl.
list_pending
(repository=None, page=None, fast=True, directories=False)¶ List the local files that are pending for upload.
-
escale.cli.ctl.
make_cache
(repository=None, prefix='cc')¶ Build the checksum cache.
-
escale.cli.ctl.
migrate
(repository=None, destination=None, fast=None)¶ Migrate a relay repository from a host to another.
Supports change in protocol and prefixes/suffixes of special files.
-
escale.cli.ctl.
rebase
(repository=None, extra_path=None)¶ Update the existing indices so that the former repository is a sub-directory of the new repository.
-
escale.cli.ctl.
recover
(repository=None, timestamp=None, overwrite=True, update=None, fast=None, page=None)¶ Make a relay repository with placeholder files or indices as if the local repository resulted from a complete download of an existing repository with escale.
-
escale.cli.ctl.
restart
(pidfile=None)¶ Restart all the running escale processes.
-
escale.cli.ctl.
restore
(repository=None, archive=None, fast=None)¶ Overwrite a relay repository with the uncompressed content of an archive.
-
escale.cli.ctl.
resume
(repository=None, page=None)¶ Release locks set by the suspend procedure.
-
escale.cli.ctl.
start
(pidfile=None)¶ Start all the client defined in the default configuration file.
This routine is the only one that records the pid of the main process in file.
-
escale.cli.ctl.
stop
(pidfile=None)¶ Kill all the running escale processes.
-
escale.cli.ctl.
suspend
(repository=None, page=None)¶ Lock pages so that the regular clients cannot push or pull.
This procedure is designed for index-based repositories only.
If a page to be locked is already locked, escalectl waits for the lock to be released.
escale.cli.config module¶
escale.cli.config.config module¶
-
class
escale.cli.config.config.
Service
(label, name, protocol=None, address=None, auth=False, rclone_docs=None)¶ Bases:
object
-
address
¶
-
auth
¶
-
label
¶
-
name
¶
-
protocol
¶
-
rclone_docs
¶
-
requires
¶
-
-
escale.cli.config.config.
add_section
(config, cfg_dir, section=None, msgs=[])¶ Add a configuration section.
Asks for information in the following order:
- local repository (path)
- remote address or locally accessible relay repository (mount)?
- locally accessible relay repository (path)
- or relay full address (protocol://address:port/path)
- section name if missing
And then delegates to
section_common()
.new in 0.7: indexing is set by default, with 200MB page size, for all relay backend but FTP and local file.
Parameters: - config (ConfigParser) – configuration object.
- cfg_dir (str) – configuration directory.
- section (str) – configuration section name.
- msgs (list) – pending messages.
Returns: updated configuration object and pending messages.
Return type: (ConfigParser, list)
-
escale.cli.config.config.
edit_config
(cfg_file, msgs=[])¶ Add or edit sections of a configuration file.
Parameters: - cfg_file (str) – path to a configuration file.
- msgs (list) – pending messages.
Returns: pending messages.
Return type: list
-
escale.cli.config.config.
edit_section
(config, cfg_dir, section, msgs=[])¶ Edit a configuration section.
Asks for information in the following order:
- local repository (path)
- if remote relay:
- relay host address (no protocol)
- relay host port (if defined in config)
- relay host directory (if defined in config)
- else if locally accessible relay repository (mount):
- path to this relay repository
And then delegates to
section_common()
.Parameters: - config (ConfigParser) – configuration object.
- cfg_dir (str) – configuration directory.
- section (str) – configuration section name.
- msgs (list) – pending messages.
Returns: updated configuration object and pending messages.
Return type: (ConfigParser, list)
-
escale.cli.config.config.
print_help
(help, space=True)¶
-
escale.cli.config.config.
query_field
(config, section, field, description=None, suggestion='', required=False, echo=True, help=None, reminder=True)¶ Request user input for a single field.
If field is in ~escale.base.config.fields, query_field will seek in config for any of the candidate options defined in fields, instead of field.
If an existing value is found, it is presented as a default value and returned as answer if the user does not input anything.
Parameters: - config (ConfigParser) – existing configuration.
- section (str) – active configuration section.
- field (str) – any key from ~escale.base.config.fields or any configuration option.
- description (str) – request text.
- suggestion (str) – an indication of default value or possible choices.
- required (bool) – if True, the request is drawn again as long as the user do not input a non-empty answer.
- echo (bool) – if False, the answer is not echoed (suitable for passwords).
- help (str) – help message displayed when the user inputs ‘?’.
- reminder (bool) – if True, a reminder about help availability is printed.
Returns: first argument is the actual option name in config. Second argument is the user’s answer.
Return type: (str, str)
-
escale.cli.config.config.
query_local_repository
(config, section=None, msgs=[])¶ Query local repository.
Unicode is alright.
Returns: configuration option and value. Return type: (str, str)
-
escale.cli.config.config.
query_relay_address
(config, section=None, remote=True, msgs=[], help=None)¶
-
escale.cli.config.config.
query_synchronization_mode
(config, section, msgs=[])¶
-
escale.cli.config.config.
section_common
(config, cfg_dir, section, protocol, msgs, return_mode=False)¶
-
escale.cli.config.config.
show_protocols
(ps)¶
-
escale.cli.config.config.
simplified_add
(config, cfg_dir, section=None, msgs=[])¶ Add a configuration section.
Asks for information in the following order:
- local repository (path)
- relay service or protocol (display list)
- if protocol, address of the service
- disk quota for the relay space (now of limited interest with indexing)
- indexing with 200MB page size
Some parameters are set or let undefined so that they default to the following settings:
- no encryption
- ‘shared’ synchronization mode
- refresh time 10s
- 2GB disk limit for the relay repository
Parameters: - config (ConfigParser) – configuration object.
- cfg_dir (str) – configuration directory.
- section (str) – configuration section name.
- msgs (list) – pending messages.
Returns: updated configuration object and pending messages.
Return type: (ConfigParser, list)