PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
288 stars 63 forks source link

sftp opener does not parse URL properly #169

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Using fs 0.4.0

This code is support so list stuff in /tmp but it returns all items from the / 
directory.

from fs.opener import opener

layer, path = opener.parse('sftp://some.host/tmp')
for x in layer.listdir():
    print x

bin/zopepy foo.py 

boot
etc
home
lib32
bin
root
selinux
media
srv
opt
aquota.user
var
debian-binary
mnt
autojump_errors
lib
sys
aquota.group
usr
fastboot
ftp
dev
tmp
sbin
lib64
proc
backup

Original issue reported on code.google.com by zopyxfilter on 14 Oct 2013 at 1:37

GoogleCodeExporter commented 9 years ago
opener.parse actually returns the filesystem object plus a path. try 
layer.listdir(path)

Original comment by willmcgugan on 14 Oct 2013 at 1:58

GoogleCodeExporter commented 9 years ago
Isn't the returned object to be a sandboxes FS object for /tmp? Why should the 
returned FS object be bound to '/' instead? This does not make sense.

Original comment by zopyxfilter on 14 Oct 2013 at 2:12

GoogleCodeExporter commented 9 years ago
There's no way to determine if 'sftp://some.host/tmp' refers to a directory or 
a file just from the url.

You probably want opener.opendir, which returns a filesystem object for a 
subdirectory.

Original comment by willmcgugan on 14 Oct 2013 at 2:41