salvus.flow.executors.remote_io_executor
Classes
LocalSFTPClient
LocalSFTPClientclass LocalSFTPClient(builtins.object):
def __init__(self): ...Everything is based on SSH but for the local site its not needed. Thus we implement a custom SFTP client on top of direct file system operations.
Initialize self. See help(type(self)) for accurate signature.
close()
close()def close(self) -> None: ...Mock method.
get()
get()def get(
self, remotepath: str, localpath: str, callback: Optional[Callable]
) -> None: ...Get a remote file.
remotepathstr — Remote path.localpathstr — Local path.callbackOptional[Callable] — Callback function.
getfo()
getfo()def getfo(
self, remotepath: str, fl: IO, callback: Optional[Callable]
) -> None: ...Get a remote file and copy it to an open file handle.
remotepathstr — Remote path.flIO — Open file handle.callbackOptional[Callable] — Callback function.
listdir()
listdir()def listdir(self, path: str) -> List[str]: ...List the contents of a directory.
pathstr — The path.
mkdir()
mkdir()def mkdir(self, path: str, mode: int = 511) -> None: ...Create directory.
pathstr — The path.modeint — Permission mode.
put()
put()def put(
self, localpath: str, remotepath: str, callback: Optional[Callable]
) -> None: ...Copy a local file to remote site.
localpathstr — Local file.remotepathstr — Remote path.callbackOptional[Callable] — Callback function.
putfo()
putfo()def putfo(
self, fl: IO, remotepath: str, callback: Optional[Callable]
) -> None: ...Put the contents of an open file handle to a remote path.
flIO — Open file handle.remotepathstr — Remote path.callbackOptional[Callable] — Callback function.
rmdir()
rmdir()def rmdir(self, path: str) -> None: ...Remove a directory.
pathstr — The path.
stat()
stat()def stat(self, path: str) -> os.stat_result: ...Return stat().
pathstr — The path.
unlink()
unlink()def unlink(self, path: str) -> None: ...Unlink the path.
pathstr — The path.
LocalSSHClient
LocalSSHClientclass LocalSSHClient(builtins.object):
def __init__(self): ...Initialize self. See help(type(self)) for accurate signature.
close()
close()def close(self) -> None: ...Mock method.
connect()
connect()def connect(self) -> None: ...Mock method.
exec_command()
exec_command()def exec_command(self) -> None: ...Mock method.
load_system_host_keys()
load_system_host_keys()def load_system_host_keys(self) -> None: ...Mock method.
open_sftp()
open_sftp()def open_sftp(self) -> None: ...Mock method.
set_missing_host_key_policy()
set_missing_host_key_policy()def set_missing_host_key_policy(self) -> None: ...Mock method.
OSType
OSTypeclass OSType(enum.Enum):
def __init__(self): ...Enumerate the type of operating system.
RemoteIOExecutor
RemoteIOExecutorclass RemoteIOExecutor(builtins.object):
def __init__(self): ...Class to encapsulate SSH/SFTP client initialization and remote I/O functionality
Not useful on its own - does require self.name and self.config to be available.
Initialize self. See help(type(self)) for accurate signature.
file_path_type Union[Type[pathlib.PurePosixPath], Type[pathlib.PureWindowsPath]]
file_path_type Union[Type[pathlib.PurePosixPath], Type[pathlib.PureWindowsPath]]Returns the type of file paths for the given site.
home_dir types
home_dir typesThe home directory.
os_type salvus.flow.executors.remote_io_executor.OSType
os_type salvus.flow.executors.remote_io_executor.OSTypeReturns the type of the operating system.
Subclasses can overwrite this.
sftp_client Union[paramiko.sftp_client.SFTPClient, salvus.flow.executors.remote_io_executor.LocalSFTPClient]
sftp_client Union[paramiko.sftp_client.SFTPClient, salvus.flow.executors.remote_io_executor.LocalSFTPClient]Get the sftp client instance.
Will be initialized upon the first access.
ssh_client Union[paramiko.client.SSHClient, salvus.flow.executors.remote_io_executor.LocalSSHClient]
ssh_client Union[paramiko.client.SSHClient, salvus.flow.executors.remote_io_executor.LocalSSHClient]Get the ssh client instance.
Will be initialized upon the first access.
execute_command()
execute_command()def execute_command(
self,
command: str,
assert_ok: bool = True,
environment: Optional[Dict[str, str]] = None,
) -> Tuple[int, List[str], List[str]]: ...Execute the command.
commandstr — The command to run as a string.assert_okbool — Raise if the command does not exist with a code of 0.environmentOptional[Dict[str, str]] — Environment variables to be set for this command.
is_folder_writeable()
is_folder_writeable()def is_folder_writeable(
self,
path: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
) -> bool: ...Return True if the user has write permissions in the chosen folder.
pathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Path on the remote machine.
remote_exists()
remote_exists()def remote_exists(
self,
path: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
) -> bool: ...Check if a remote file or directory exists.
pathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Path to check.
remote_get()
remote_get()def remote_get(
self,
remotepath: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
localpath: Union[_io.BytesIO, pathlib.Path],
show_progressbar: bool = False,
) -> None: ...Get a remote file.
remotepathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Remote file to get.localpathUnion[_io.BytesIO, pathlib.Path] — Local path to save to Can be a file or a file like object.show_progressbarbool — Show a progressbar or not.
remote_listdir()
remote_listdir()def remote_listdir(
self,
path: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
) -> List[str]: ...List the contents of a remote directory.
Just dispatches to the underlying representation.
pathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Remote path whose contents to list.
remote_mkdir()
remote_mkdir()def remote_mkdir(
self,
path: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
mode: int = 511,
) -> None: ...Create a directory on the remote or local machine.
pathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Directory to create.modeint — Permissions for the new directory.
remote_put()
remote_put()def remote_put(
self,
localpath: Union[_io.BytesIO, pathlib.Path],
remotepath: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
show_progressbar: bool = False,
) -> None: ...Copy a local file to a remote path.
localpathUnion[_io.BytesIO, pathlib.Path] — Local file to copy. Can be a file like object.remotepathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Where to copy to.show_progressbarbool — Show a progressbar or not.
remote_rmdir()
remote_rmdir()def remote_rmdir(
self,
path: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
verbosity: int = 1,
) -> None: ...Remotely and recursively delete a remote folder and its contents.
pathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Remote path to delete.verbosityint — Verbosity level.
safe_remote_rmdir()
safe_remote_rmdir()def safe_remote_rmdir(
self,
path: Union[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
],
allow_failure: bool,
verbosity: int = 1,
) -> None: ...Convenience wrapper that optionally allows the remote_rmdir() command to fail. Useful for some networked file systems.
pathUnion[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Remote path to delete.allow_failurebool — Whether to allow failure or not.verbosityint — Verbosity level.