[ftputil] Issue with Hidden Directories
Alexander Michael
lxander.m at gmail.com
Thu Oct 20 20:56:52 CEST 2005
I am attempting to use ftputil (version 2.0.3) with Python 2.4.1 to pull
files from a data vendor's server [331-(220 pawn Microsoft FTP Service
(Version 5.0).)], but ran into a small issue. Here's what the failure looks
like:
Traceback (most recent call last):
File "updatefiles.py", line 210, in cli
outgoingdir=ostools.nativepath(opts.outgoing_dir))
File "updatefiles.py", line 128, in update
ftp_update(basedir, host, proxy, outgoingdir)
File "updatefiles.py", line 91, in ftp_update
filenames = host.listdir('')
File "C:\Python24\Lib\site-packages\ftputil\ftputil.py", line 634, in
listdir
return self._stat.listdir(path)
File "C:\Python24\Lib\site-packages\ftputil\ftp_stat.py", line 115, in
listdir
raise ftp_error.PermanentError("550 %s: no such directory" % path)
PermanentError: 550 /johndoe: no such directory
Looking around "C:\Python24\Lib\site-packages\ftputil\ftp_stat.py", line
115, I see:
path = self._path.abspath(path)
if not self._path.isdir(path):
raise ftp_error.PermanentError("550 %s: no such directory" % path)
I think the issue revolves around the fact the vendor has the FTP account
setup so that I get dropped into a subdirectory (with the same name as my
username), but the directory isn't visible one level up. As result, the
lstat method fails to determine that path is a directory. After changing the
above to be:
path = self._path.abspath(path)
if path != self._host.getcwd() and not self._path.isdir(path):
raise ftp_error.PermanentError("550 %s: no such directory" % path)
so that it doesn't fail for the current working directory, everything works
great. I'm not sure if there is a better or more efficient way to be robust
to this situation, but this worked for me. I am not sure if I can rest
assured that the current working directory is in fact a directory, but it
seems to make some sense.
Thanks for making this useful module available (and under a nice license).
Regards,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/ftputil/attachments/20051020/3641bf00/attachment.htm
More information about the ftputil
mailing list