Skip to content

Commit 7ddc350

Browse files
author
Pan
committed
Updated sftp open documentation, example and readme for compatibility.
Resolves #13.
1 parent 545b0f3 commit 7ddc350

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

README.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ API Feature Set
4747
________________
4848

4949

50-
Currently the vast majority of the `libssh2`_ API has been implemented with only few exceptions.
50+
At this time all of the `libssh2`_ API has been implemented up to version ``1.8.0``.
5151

5252
Complete example scripts for various operations can be found in the `examples directory`_.
5353

@@ -179,9 +179,12 @@ SFTP Read
179179

180180
.. code-block:: python
181181
182+
from ssh2.sftp import LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR
183+
182184
sftp = session.sftp_init()
183-
with sftp.open(<remote file to read>, 0, 0) as remote_fh, \
184-
open(<file to write>, 'wb') as local_fh:
185+
with sftp.open(<remote file to read>,
186+
LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR) as remote_fh, \
187+
open(<local file to write>, 'wb') as local_fh:
185188
for size, data in remote_fh:
186189
local_fh.write(data)
187190
@@ -247,6 +250,7 @@ ________________________________________
247250
* SCP send and receive
248251
* Listener for port forwarding
249252
* Subsystem support
253+
* Host key checking and manipulation
250254

251255
And more, as per `libssh2`_ functionality.
252256

examples/sftp_read.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from datetime import datetime
1313

1414
from ssh2.session import Session
15+
from ssh2.sftp import LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR
1516

1617

1718
USERNAME = pwd.getpwuid(os.geteuid()).pw_name
@@ -37,7 +38,7 @@ def main():
3738
sftp = s.sftp_init()
3839
now = datetime.now()
3940
print("Starting read for remote file %s" % (args.file,))
40-
with sftp.open(args.file, 0, 0) as fh:
41+
with sftp.open(args.file, LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR) as fh:
4142
for size, data in fh:
4243
pass
4344
print("Finished file read in %s" % (datetime.now() - now,))

ssh2/sftp.c

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh2/sftp.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,18 @@ cdef class SFTP:
155155
156156
:param filename: Name of file to open.
157157
:type filename: str
158-
:param flags: One or more LIBSSH2_FXF_* flags. Can be ``0`` for
159-
reading.
158+
:param flags: One or more LIBSSH2_FXF_* flags.
160159
161160
Eg for reading flags is ``LIBSSH2_FXF_READ``,
162161
163162
for writing ``LIBSSH2_FXF_WRITE``,
164163
165164
for both ``LIBSSH2_FXF_READ`` | ``LIBSSH2_FXF_WRITE``.
166165
:type flags: int
167-
:param mode: File permissions mode. ``0`` for reading.
166+
:param mode: File permissions mode. ``LIBSSH2_SFTP_S_IRUSR`` for
167+
reading.
168168
169-
For writing one or more LIBSSH2_SFTP_S_* flags.
169+
For writing one or more ``LIBSSH2_SFTP_S_*`` flags.
170170
171171
Eg, for 664 permission mask (read/write owner/group, read other),
172172

0 commit comments

Comments
 (0)