Ticket #33 (closed defect: fixed)
FTPHost.listdir fails for some servers if the path contains slashes
| Reported by: | ftputiluser | Owned by: | schwa |
|---|---|---|---|
| Priority: | major | Milestone: | 2.4.2 |
| Component: | Library | Version: | 2.4 |
| Keywords: | listdir, change directory, special_case | Cc: |
Description (last modified by schwa) (diff)
Ftputil doesn't correctly list the content for some sites such as ftp.gnome.org .
>>> import ftputil
>>> conn=ftputil.FTPHost('ftp.gnome.org','anonymous','pippo@pippo.com')
>>> conn.listdir('/')
['pub']
(should be ['HEADER.html', 'Public', 'about', 'cdimage', 'conspiracy', 'debian', 'debian-cd', 'debian-non-US', 'favicon.ico', 'mirror', 'pub' , 'releases', 'robots.txt', 'ubuntu', 'welcome.msg', 'welcome2.msg']).
I think the problem is derived from python standard ftplib
>>> ftp = ftplib.FTP('ftp.gnome.org')
>>> ftp.login()
'230 Login successful.'
>>> ftp.dir('/')
drwxr-xr-x 4 ftp ftp 15 Dec 19 14:31 pub
However with the standard python library there is the following workaround:
>>> ftp.cwd(path) >>> ftp.dir()
To apply this to ftputil it's enough to modify _robust_ftp_command method (line 562 in ftputil.py) and always use the code for 'special_case'.
If this small modification doesn't break anything I think it could be applied to ftputil,
regards Nicola
