Python module#

Dataset#

SSH interface#

shelephant.ssh.is_file(hostname, path[, verbose])

Check if a file exists on a remote system.

shelephant.ssh.is_dir(hostname, path[, verbose])

Check if a directory exists on a remote system.

shelephant.ssh.has_keys_set(hostname)

Check if the ssh keys are set for a given host.

shelephant.ssh.tempdir(hostname)

Create a temporary directory on a remote system.

scp interface#

shelephant.scp.copy(source_dir, dest_dir, files)

Copy files using scp.

rsync interface#

local interface#

Type conversion#

YAML handling#

File information#

shelephant.info.getinfo(files[, sha256, ...])

Get the sha256 hash and size of a list of files.

File operations#

Formatted print#

Command-line interface#

Details#

convert#

dataset#

info#

shelephant.info.getinfo(files: list[pathlib.Path], sha256: bool = True, progress: bool = True) tuple[list[str], list[int]]#

Get the sha256 hash and size of a list of files.

Parameters
  • files – A list of files.

  • sha256 – Calculate the sha256 hash.

  • progress – Show a progress bar.

Returns

A tuple of lists of (size, mtime, sha256).

local#

output#

path#

rsync#

scp#

shelephant.scp.copy(source_dir: str, dest_dir: str, files: list[str], options: str = '-p', verbose: bool = False, progress: bool = True)#

Copy files using scp.

Parameters
  • source_dir – Source directory. If remote: [user@]host:path.

  • dest_dir – Source directory. If remote: [user@]host:path.

  • files – List of file-paths (relative to source_dir and dest_dir).

  • options – Options passed to scp.

  • verbose – Verbose commands.

  • progress – Show progress bar.

search#

shelephant.search.cwd(dirname: Path)#

Set the cwd to a specified directory:

with cwd("foo"):
    # Do something in foo
Parameters

dirname – The directory to change to.

shelephant.search.search(*settings: dict, root: Path = PosixPath('.')) list[pathlib.Path]#

Search for files using a list of settings, as follows:

[
    {"rglob": "*.py", "skip": ["\..*", "build"]},
    {"exec": "find . -name '*.cpp'"},
]
Parameters
  • settings – A list of settings.

  • root – The root directory to search in.

Returns

A list of paths.

shelephant.search.tempdir()#

Set the cwd to a temporary directory:

with tempdir("foo"):
    # Do something in foo

ssh#

shelephant.ssh.has_keys_set(hostname: str) bool#

Check if the ssh keys are set for a given host.

Parameters

hostname – Hostname.

Returns

True if the host can be accessed without password.

shelephant.ssh.is_dir(hostname: str, path: str, verbose: bool = False) bool#

Check if a directory exists on a remote system. Uses ssh.

Parameters
  • hostname – Hostname.

  • path – Directory (path on hostname).

  • verbose – Verbose commands.

Returns

True if the file exists, False otherwise.

shelephant.ssh.is_file(hostname: str, path: str, verbose: bool = False) bool#

Check if a file exists on a remote system. Uses ssh.

Parameters
  • hostname – Hostname.

  • path – Filename (path on hostname).

  • verbose – Verbose commands.

Returns

True if the file exists, False otherwise.

shelephant.ssh.tempdir(hostname: str)#

Create a temporary directory on a remote system. Uses ssh.

with tempdir(“localhost”) as remote_tempdir:

print(remote_tempdir)

yaml#