cptree package#

Submodules#

cptree.checksum module#

cptree.checksum.checksum(target, hash, output_file, tqdm_kwargs=None, rsync_args=None, src=None, dst=None)[source]#

generate BSD-style checksum for each file in target, returning local file containing result

cptree.checksum.checksum_command(base, host, exclude_filename, hash_cmd)[source]#
cptree.checksum.compare_checksums(src_sums, dst_sums)[source]#

run diff on hash digest files, return length if identical, otherwise raise exception

cptree.checksum.delete_exclude_file(host, filename)[source]#
cptree.checksum.delete_file(filename)[source]#
cptree.checksum.generate_exclude_file(host, rsync_args)[source]#
cptree.checksum.is_local(host)[source]#
cptree.checksum.is_remote(host)[source]#

cptree.cli module#

Console script for cptree.

cptree.common module#

cptree.common.host_mode(host)[source]#
cptree.common.map_cmd(command)[source]#
cptree.common.parse_int(field)[source]#
cptree.common.read_file_lines(filename, strip=True)[source]#
cptree.common.runner(host)[source]#
cptree.common.split_target(target: str) -> (<class 'str'>, <class 'str'>)[source]#

return (hostname, path) for target; hostname is None for local target

cptree.common.which(command, host=None, quiet=False)[source]#

return local or remote command path if valid, otherwise raise exception or optionally return None

cptree.common.write_file_lines(dir, name, lines)[source]#

cptree.cptree module#

cptree.cptree.check_for_device_transfers(counts, file_list)[source]#
cptree.cptree.count_items(items)[source]#
cptree.cptree.cptree(*args, output_dir=None, **kwargs)[source]#

call _cptree with work_dir from argument or a temp dir

cptree.cptree.mkopts(kwargs)[source]#
cptree.cptree.prescan(src, dst, cmd, opts, file_list)[source]#
cptree.cptree.summarize_item_details(counts)[source]#

cptree.exception_handler module#

ehandler

well-behaved exception handler for python cli commands

class cptree.exception_handler.ExceptionHandler(debug=False, logger=False)[source]#

Bases: object

debug = None#
installed = False#
logger = None#
cptree.exception_handler.exception_handler(exception_type, exception, traceback, debug_hook=<built-in function excepthook>)[source]#

cptree.exceptions module#

exception cptree.exceptions.ChecksumCompareFailed[source]#

Bases: Fail

exception cptree.exceptions.ChecksumExcludeFileGenerationFailed[source]#

Bases: Fail

exception cptree.exceptions.ChecksumGenerationFailed[source]#

Bases: Fail

exception cptree.exceptions.CommandNotFound[source]#

Bases: Fail

exception cptree.exceptions.Fail[source]#

Bases: Exception

exception cptree.exceptions.InvalidDirectory[source]#

Bases: Fail

exception cptree.exceptions.RsyncTransferFailed[source]#

Bases: Fail

exception cptree.exceptions.UnrecognizedRsyncPrescanOutput[source]#

Bases: Fail

exception cptree.exceptions.UnsupportedRsyncArgument[source]#

Bases: Fail

cptree.exclude module#

cptree.exclude.glob_to_egrep(glob_pattern)[source]#

Convert a glob pattern to a regex pattern usable by egrep.

Args: - glob_pattern (str): The glob pattern to convert.

Returns: - str: A regex pattern equivalent to the input glob pattern.

cptree.exclude.rsync_exclude_patterns(rsync_args)[source]#

parse rsync args and return list of exclude patterns as regex

cptree.progress module#

class cptree.progress.ProgressReader(in_stream, **kwargs)[source]#

Bases: object

readlines()[source]#

cptree.shell module#

cptree.verify module#

cptree.verify.confirm_delete(target, label, host, delete)[source]#
cptree.verify.delete_countdown(msg, cmd, host)[source]#
cptree.verify.verify_dst_directory(target, create=None, delete=None)[source]#
cptree.verify.verify_output_directory(target)[source]#
cptree.verify.verify_src_directory(target)[source]#

cptree.version module#

cptree.watcher module#

class cptree.watcher.LineWatcher(*, file_callback=None, progress_callback=None, line_callback=None)[source]#

Bases: StreamWatcher

parse_line(line)[source]#
submit(stream: str) Generator[str, None, None][source]#

Act on stream data, potentially returning responses.

Parameters:

stream (str) – All data read on this stream since the beginning of the session.

Returns:

An iterable of str (which may be empty).

New in version 1.0.

Module contents#

Top-level package for cptree.

cptree.cptree(*args, output_dir=None, **kwargs)[source]#

call _cptree with work_dir from argument or a temp dir