server

Misc. functions to utilizes server.

pdm_utils.functions.server.get_transport(host)

Create paramiko Transport with the server name.

Parameters

host (str) – Server to connect to.

Returns

Paramiko Transport object. If the server is not available, None is returned.

Return type

Transport

pdm_utils.functions.server.set_log_file(filepath)

Set the filepath used to stored the Paramiko output.

This is a soft requirement for compliance with Paramiko standards. If it is not set, paramiko throws an error.

Parameters

filepath (Path) – Path to file to log Paramiko results.

pdm_utils.functions.server.setup_sftp_conn(transport, user=None, pwd=None, attempts=1)

Get credentials and setup connection to the server.

Parameters
  • transport (Transport) – Paramiko Transport object directed towards a valid server.

  • attempts (int) – Number of attempts to connect to the server.

Returns

Paramiko SFTPClient connection. If no connection can be made, None is returned.

Return type

SFTPClient

pdm_utils.functions.server.upload_file(sftp, local_filepath, remote_filepath)

Upload a file to the server.

Parameters
  • sftp (SFTPClient) – Paramiko SFTPClient connection to a server.

  • local_filepath (str) – Absoluate path to file to be uploaded.

  • remote_filepath (str) – Absoluate path to server destination.

Returns

Indicates whether upload was successful.

Return type

bool