FileClient
FileClient#
- class atomate2.utils.file_client.FileClient(key_filename: str | Path = '~/.ssh/id_rsa', config_filename: str | Path = '~/.ssh/config')[source]#
Bases:
object
Tool for performing operations on files.
The client is agnostic of whether file operations are happening locally or via SSH. All operations have a
host
parameter that specifies which remote host the operation should be performed on.Note
To use abbreviated host names without user information, the FileClient requires the appropriate configuration to be defined in the ssh config file.
- Parameters
- connect(host: str)[source]#
Connect to a remote host.
- Parameters
- host
str
A remote host filesystem. Supports using hosts defined in the ssh config file. The host can be specified as either “username@remote_host” or just “remote_host” in which case the username will be inferred from the current user.
- host
- get_ssh(host: str) paramiko.client.SSHClient [source]#
Get an SSH connection to a host.
- Parameters
- host
str
A remote host filesystem. Supports using hosts defined in the ssh config file. The host can be specified as either “username@remote_host” or just “remote_host” in which case the username will be inferred from the current user.
- host
- Returns
SSHClient
An ssh client to the host.
- get_sftp(host: str) paramiko.sftp_client.SFTPClient [source]#
Get an SFTP connection to a host.
- Parameters
- host
str
A remote host filesystem. Supports using hosts defined in the ssh config file. The host can be specified as either “username@remote_host” or just “remote_host” in which case the username will be inferred from the current user.
- host
- Returns
SFTPClient
An sftp client to the host.
- listdir(path: str | Path, host: Optional[str] = None) list[Path] [source]#
Get the directory listing.
- copy(src_filename: str | Path, dest_filename: str | Path, src_host: Optional[str] = None, dest_host: Optional[str] = None)[source]#
Copy a file from source to destination.
- remove(path: str | Path, host: Optional[str] = None)[source]#
Remove a file (does not work on directories).
- rename(old_path: str | Path, new_path: str | Path, host: Optional[str] = None)[source]#
Rename (move) a file.
- gzip(path: str | Path, host: Optional[str] = None, compresslevel: int = 6, force: bool = False)[source]#
Gzip a file.