Skip to content

Fixes #1255: Add os.path-like stat-based methods to SFTPClient - #1259

Open
GPHemsley wants to merge 2 commits into
paramiko:mainfrom
GPHemsley:gh-1255
Open

GPHemsley wants to merge 2 commits into
paramiko:mainfrom
GPHemsley:gh-1255

Conversation

@GPHemsley

@GPHemsley GPHemsley commented Aug 9, 2018 •

Copy link
Copy Markdown

Fixes #1255: Add os.path-like stat-based methods to SFTPClient

Add methods to SFTPClient that resemble equivalent methods from
os.path:

  • exists
  • lexists
  • isfile
  • islink
  • isdir

All of these methods are based on the results of calling stat on a
path, except lexists, which is based on lstat.

These methods reduce the need for a user of the paramiko library
to import the Python stat module and inspect the return value of
an SFTPClient.stat call.

@GPHemsley
GPHemsley force-pushed the gh-1255 branch 2 times, most recently from c81f761 to ba985f7 Compare August 9, 2018 03:11
Add methods to `SFTPClient` that resemble equivalent methods from
`os.path`:
 * `exists`
 * `lexists`
 * `isfile`
 * `islink`
 * `isdir`

All of these methods are based on the results of calling `stat` on a
path, except `lexists`, which is based on `lstat`.

These methods reduce the need for a user of the paramiko library
to import the Python `stat` module and inspect the return value of
an `SFTPClient.stat` call.
@GPHemsley

Copy link
Copy Markdown
Author

@bitprophet This is ready for your review.

@bitprophet bitprophet added this to the 2.5.0 milestone Sep 6, 2018
@bitprophet

Copy link
Copy Markdown
Member

Thanks, popped it into next milestone so I don't forget it.

Also a note to myself: this may impact Patchwork (Fabric 2's contrib library) which reimplements some of this stuff via shell commands. However, since not all remote targets will necessarily have SFTP enabled, that's probably no bueno; but we could maybe implement it in a tiered fallback manner (try SFTP, if SFTP seems disabled, use test or w/e).

@bitprophet bitprophet modified the milestones: p0, p2 Oct 16, 2018
@uscivics

Copy link
Copy Markdown

is this going to be merged? Should I fork this in the interim?

@JohnPreston

Copy link
Copy Markdown

This is old, but still. Bump

@wbarnha

wbarnha commented Mar 14, 2023 •

Copy link
Copy Markdown

I'd like these features added so I can move away from https://bitbucket.org/dundeemt/pysftp. Bumping for attention!

@wbarnha

wbarnha commented Apr 13, 2023

Copy link
Copy Markdown

Seems like this PR has been forgotten, so I created a fork in https://github.com/wbarnha/paramiko-stat that acts like a wrapper.

@bskinn

bskinn commented May 11, 2023

Copy link
Copy Markdown
Contributor

Not forgotten, @wbarnha, just falling below some other, major work in the priority queue for bitprophet's limited open source time. First was dropping Python 2 and old Python 3.x; now the key/auth overhaul of #387, #23, and related.

bitprophet has this sorted into a prioritization milestone -- once these big tasks are out of the way, he'll be moving on to features & fixes like this.

Sorry for the wait; we'll get there, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emulate exists, isdir, isfile from os.path in SFTP connection

6 participants