Skip to content

Commit

Permalink
adding documentation for new worker attribute, updating release date …
Browse files Browse the repository at this point in the history
…due to the procrastination of documentation
  • Loading branch information
byteskeptical committed Oct 24, 2023
1 parent 7a362df commit 10f6ffc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Example
SSHException), tries=6)
# Use public key authentication
# Use public key authentication
with Connection('hostname', private_key='~/.ssh/id_ed25519') as sftp:
# Resume the download of a bigfile and save it to /mnt locally.
sftp.get('bigfile', '/mnt', preserve_mtime=True, resume=True)
Expand All @@ -73,9 +73,9 @@ Example
# Recursively download a remote_directory and save it to /tmp locally.
# Don't confirm files, useful in a scenario where the server removes
# the remote file immediately after download. Preserve remote mtime on
# local copy.
# local copy. Limit the thread pool connections to the server.
sftp.get_r('remote_directory', '/tmp', confirm=False,
preserve_mtime=True)
preserve_mtime=True, workers=6)
# Use OpenSSH format config for public key authentication. Configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Change Log
==========

1.1.2 (current, released 2023-10-18)
1.1.2 (current, released 2023-10-24)
------------------------------------
* added support for setting max_workers on ThreadPool functions

Expand Down
24 changes: 16 additions & 8 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,27 @@ destination path matching.
:meth:`sftpretty.Connection.get_d`
----------------------------------
This sftpretty method is an abstraction above :meth:`.get` that allows you to
copy all the files in a remote directory to a local path.
copy all the files in a remote directory to a local path. This is a
multi-threaded function that can quickly surpass the remote server's concurrent
connection threshold for directories with many files. The workers attribute is
provided to allow for a more granular level of control of the thread pool only.

.. code-block:: python
# copy all files under public to a local path, preserving modification time
sftp.get_d('public', 'local-backup', preserve_mtime=True)
sftp.get_d('public', 'local-backup', preserve_mtime=True, workers=4)
:meth:`sftpretty.Connection.get_r`
----------------------------------
This sftpretty method is an abstraction that recursively copies files *and*
directories from the remote to a local path.
directories from the remote to a local path. Advice about managing concurrent
connections from above still applies.

.. code-block:: python
# copy all files *and* directories under public to a local path
sftp.get_r('public', 'local-backup', preserve_mtime=True)
sftp.get_r('public', 'local-backup', preserve_mtime=True, workers=16)
:meth:`sftpretty.Connection.put`
Expand All @@ -260,26 +264,30 @@ destination path matching.
:meth:`sftpretty.Connection.put_d`
----------------------------------
The opposite of :meth:`.get_d`, put_d allows you to copy the contents of a
local directory to a remote one via SFTP.
local directory to a remote one via SFTP. This is multi-threaded function that
can quickly surpass the remote server's concurrent connection threshold. The
workers attribute is provided to allow for a more granular level of control of
the thread pool only.

.. code-block:: python
# copy files from images, to remote static/images directory,
# preserving modification times on files
sftp.put_d('images', 'static/images', preserve_mtime=True)
sftp.put_d('images', 'static/images', preserve_mtime=True, workers=6)
:meth:`sftpretty.Connection.put_r`
----------------------------------
This method copies all files *and* directories from a local path to a remote
path. It creates directories, and happily succeeds even if the target
directories already exist.
directories already exist. Advice about managing concurrent connections from
above still applies.

.. code-block:: python
# recursively copy files + directories from local static, to remote static,
# preserving modification times on directories and files
sftp.put_r('static', 'static', preserve_mtime=True)
sftp.put_r('static', 'static', preserve_mtime=True, workers=12)
:meth:`sftpretty.Connection.cd`
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Example
# Recursively download a remote_directory and save it to /tmp locally.
# Don't confirm files, useful in a scenario where the server removes
# the remote file immediately after download. Preserve remote mtime on
# local copy. Limit the concurrent connections to the server.
# local copy. Limit the thread pool connections to the server.
sftp.get_r('remote_directory', '/tmp', confirm=False,
preserve_mtime=True, workers=6)
Expand Down

0 comments on commit 10f6ffc

Please sign in to comment.